diff --git a/src/Client/Content/Content.mgcb b/src/Client/Content/Content.mgcb index b857953..9b70229 100644 --- a/src/Client/Content/Content.mgcb +++ b/src/Client/Content/Content.mgcb @@ -13,7 +13,45 @@ #---------------------------------- Content ---------------------------------# -#begin Textures/playerShip1_blue.png +#begin Audio/backgroundMusic.mp3 +/importer:Mp3Importer +/processor:SongProcessor +/processorParam:Quality=Best +/build:Audio/backgroundMusic.mp3 + +#begin Audio/menu.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Audio/menu.mp3 + +#begin Audio/menuSelect.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Audio/menuSelect.mp3 + +#begin Audio/success.mp3 +/importer:Mp3Importer +/processor:SoundEffectProcessor +/processorParam:Quality=Best +/build:Audio/success.mp3 + +#begin Fonts/menu-select.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/menu-select.spritefont + +#begin Fonts/menu.spritefont +/importer:FontDescriptionImporter +/processor:FontDescriptionProcessor +/processorParam:PremultiplyAlpha=True +/processorParam:TextureFormat=Compressed +/build:Fonts/menu.spritefont + +#begin Images/background.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -23,9 +61,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/playerShip1_blue.png +/build:Images/background.png -#begin Textures/playerShip1_red.png +#begin Images/MenuBackground.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -35,9 +73,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/playerShip1_red.png +/build:Images/MenuBackground.png -#begin Textures/head.png +#begin Textures/body.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -47,9 +85,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/head.png +/build:Textures/body.png -#begin Textures/body.png +#begin Textures/head.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -59,9 +97,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/body.png +/build:Textures/head.png -#begin Textures/tail.png +#begin Textures/playerShip1_blue.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -71,24 +109,21 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Textures/tail.png - - -#begin Fonts/menu.spritefont -/importer:FontDescriptionImporter -/processor:FontDescriptionProcessor -/processorParam:PremultiplyAlpha=True -/processorParam:TextureFormat=Compressed -/build:Fonts/menu.spritefont +/build:Textures/playerShip1_blue.png -#begin Fonts/menu-select.spritefont -/importer:FontDescriptionImporter -/processor:FontDescriptionProcessor +#begin Textures/playerShip1_red.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False /processorParam:PremultiplyAlpha=True -/processorParam:TextureFormat=Compressed -/build:Fonts/menu-select.spritefont +/processorParam:ResizeToPowerOfTwo=False +/processorParam:MakeSquare=False +/processorParam:TextureFormat=Color +/build:Textures/playerShip1_red.png -#begin Images/MenuBackground.png +#begin Textures/SandTile.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -98,9 +133,9 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Images/MenuBackground.png +/build:Textures/SandTile.png -#begin Images/background.png +#begin Textures/tail.png /importer:TextureImporter /processor:TextureProcessor /processorParam:ColorKeyColor=255,0,255,255 @@ -110,30 +145,5 @@ /processorParam:ResizeToPowerOfTwo=False /processorParam:MakeSquare=False /processorParam:TextureFormat=Color -/build:Images/background.png - -#begin Audio/success.mp3 -/importer:Mp3Importer -/processor:SoundEffectProcessor -/processorParam:Quality=Best -/build:Audio/success.mp3 - -#begin Audio/backgroundMusic.mp3 -/importer:Mp3Importer -/processor:SongProcessor -/processorParam:Quality=Best -/build:Audio/backgroundMusic.mp3 - -#begin Audio/menuSelect.mp3 -/importer:Mp3Importer -/processor:SoundEffectProcessor -/processorParam:Quality=Best -/build:Audio/menuSelect.mp3 - -#begin Audio/menu.mp3 -/importer:Mp3Importer -/processor:SoundEffectProcessor -/processorParam:Quality=Best -/build:Audio/menu.mp3 - +/build:Textures/tail.png diff --git a/src/Client/Content/Textures/SandTile.png b/src/Client/Content/Textures/SandTile.png new file mode 100644 index 0000000..5fde7e2 Binary files /dev/null and b/src/Client/Content/Textures/SandTile.png differ diff --git a/src/Client/GameModel.cs b/src/Client/GameModel.cs index 024fc4c..3bb1344 100644 --- a/src/Client/GameModel.cs +++ b/src/Client/GameModel.cs @@ -26,6 +26,7 @@ public class GameModel private Controls m_controls; private GraphicsDeviceManager m_graphics; private SpriteFont m_font; + private Texture2D m_sand; /// /// This is where everything performs its update. @@ -56,11 +57,13 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch) public bool initialize(ContentManager contentManager, Controls controls, GraphicsDeviceManager graphics) { m_font = contentManager.Load("Fonts/menu"); + m_sand = contentManager.Load("Textures/SandTile"); + m_contentManager = contentManager; m_entities = new Dictionary(); m_systemInterpolation = new Systems.Interpolation(); m_systemCamera = new Systems.Camera(new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight)); - m_renderer = new Systems.Renderer(m_systemCamera, graphics, m_font); + m_renderer = new Systems.Renderer(m_systemCamera, graphics, m_font, m_sand); m_systemWormMovement = new Shared.Systems.WormMovement(); m_systemNetwork = new Systems.Network(); @@ -111,19 +114,19 @@ private Entity createEntity(Shared.Messages.NewEntity message) { entity.add(new Shared.Components.Input(message.inputs)); } - + if (message.hasCollision) { entity.add(new Collision()); } - + // Worm parts - + if (message.hasHead) { entity.add(new Head()); } - + if (message.hasTail) { entity.add(new Tail()); @@ -138,7 +141,7 @@ private Entity createEntity(Shared.Messages.NewEntity message) { entity.add(new ChildId(message.childId)); } - + if (message.hasWorm) { entity.add(new Worm()); diff --git a/src/Client/Systems/Camera.cs b/src/Client/Systems/Camera.cs index 7e1c3d4..da47396 100644 --- a/src/Client/Systems/Camera.cs +++ b/src/Client/Systems/Camera.cs @@ -10,7 +10,7 @@ public class Camera : Shared.Systems.System { private Rectangle m_viewport = new(); public Rectangle Viewport { get { return m_viewport; } } - private float m_zoom = 1.0f; + private float m_zoom = 0.6f; public float Zoom { get { return m_zoom; } } public Camera(Vector2 viewportSize) : diff --git a/src/Client/Systems/Renderer.cs b/src/Client/Systems/Renderer.cs index 71b9d9b..a9604cd 100644 --- a/src/Client/Systems/Renderer.cs +++ b/src/Client/Systems/Renderer.cs @@ -18,8 +18,9 @@ public class Renderer : Shared.Systems.System private Systems.Camera m_camera; private GraphicsDeviceManager m_graphics; private SpriteFont m_font; + private Texture2D m_sand; - public Renderer(Systems.Camera camera, GraphicsDeviceManager graphics, SpriteFont font) : + public Renderer(Systems.Camera camera, GraphicsDeviceManager graphics, SpriteFont font, Texture2D sand) : base( typeof(Position), typeof(Sprite) ) @@ -27,6 +28,7 @@ public Renderer(Systems.Camera camera, GraphicsDeviceManager graphics, SpriteFon m_camera = camera; m_graphics = graphics; m_font = font; + m_sand = sand; } public override void update(TimeSpan elapsedTime) { } @@ -36,20 +38,33 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch) float scale = m_camera.Zoom; Matrix matrix = Matrix.Identity; Vector2 offset = -m_camera.Viewport.Location.ToVector2() - + new Vector2(m_camera.Viewport.Width,m_camera.Viewport.Height) / scale / 2; + + new Vector2(m_camera.Viewport.Width, m_camera.Viewport.Height) / scale / 2; float scaleX = m_graphics.PreferredBackBufferWidth / (float)m_camera.Viewport.Width * scale; float scaleY = m_graphics.PreferredBackBufferHeight / (float)m_camera.Viewport.Height * scale; matrix *= Matrix.CreateTranslation(new Vector3(offset, 0)); matrix *= Matrix.CreateScale(scaleX, scaleY, 1); - // spriteBatch.Begin(transformMatrix: matrix); - spriteBatch.Begin(); + //spriteBatch.Begin(); + spriteBatch.Begin(transformMatrix: matrix); + + Rectangle rect = new(0, 0, 500, 500); + spriteBatch.Draw( + m_sand, + rect, + null, + Color.White, + 0, + Vector2.Zero, + SpriteEffects.None, + 0 + ); + var heads = new List(); var bodies = new List(); var tails = new List(); var others = new List(); - + foreach (Entity entity in m_entities.Values) { if (entity.contains()) @@ -61,7 +76,7 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch) else others.Add(entity); } - + foreach (Entity entity in others) { renderEntity(elapsedTime, spriteBatch, entity); @@ -78,7 +93,7 @@ public void render(TimeSpan elapsedTime, SpriteBatch spriteBatch) { renderEntity(elapsedTime, spriteBatch, entity); } - + spriteBatch.End(); } @@ -113,7 +128,5 @@ private void renderEntity(TimeSpan elapsedTime, SpriteBatch spriteBatch, Entity Vector2 namePosition = new Vector2(position.X - size.X + 10, position.Y - size.Y - 10); Drawing.DrawPlayerName(m_font, entity.get().name, namePosition, Color.White, spriteBatch); } - } - } diff --git a/src/Shared/Systems/WormMovement.cs b/src/Shared/Systems/WormMovement.cs index dc8b57a..1673b15 100644 --- a/src/Shared/Systems/WormMovement.cs +++ b/src/Shared/Systems/WormMovement.cs @@ -34,12 +34,12 @@ public override void update(TimeSpan elapsedTime) public static void ninetyLeft(Entity head, TimeSpan elapsedTime) { - applyLeftRotation(head, -90); + applyLeftRotation(head, -MathHelper.PiOver2); } public static void ninetyRight(Entity head, TimeSpan elapsedTime) { - applyRightRotation(head, 90); + applyRightRotation(head, MathHelper.PiOver2); } private static Entity getHead(Entity entity, Dictionary entities) @@ -139,20 +139,18 @@ private void applyThrust(Entity wormHead, TimeSpan elapsedTime) // We don't need to update the entire worm with these because it will be updated in the next frame when thrust is applied - private static void applyLeftRotation(Entity head, int degrees) + private static void applyLeftRotation(Entity head, float radians) { var position = head.get(); var movement = head.get(); - // Rotate left 90 degrees - position.orientation += degrees; + position.orientation += radians; } - private static void applyRightRotation(Entity head, int degrees) + private static void applyRightRotation(Entity head, float radians) { var position = head.get(); var movement = head.get(); - // Rotate right 90 degrees - position.orientation += degrees; + position.orientation += radians; } } \ No newline at end of file