diff --git a/MonoGame.Extended/Game1/Content/Content.mgcb b/MonoGame.Extended/Game1/Content/Content.mgcb index e50d849f..652cff6d 100644 --- a/MonoGame.Extended/Game1/Content/Content.mgcb +++ b/MonoGame.Extended/Game1/Content/Content.mgcb @@ -24,3 +24,14 @@ /processorParam:TextureFormat=Color /build:shadedDark42.png +#begin hills.png +/importer:TextureImporter +/processor:TextureProcessor +/processorParam:ColorKeyColor=255,0,255,255 +/processorParam:ColorKeyEnabled=True +/processorParam:GenerateMipmaps=False +/processorParam:PremultiplyAlpha=True +/processorParam:ResizeToPowerOfTwo=False +/processorParam:TextureFormat=Color +/build:hills.png + diff --git a/MonoGame.Extended/Game1/Content/hills.png b/MonoGame.Extended/Game1/Content/hills.png new file mode 100644 index 00000000..a5bfba65 Binary files /dev/null and b/MonoGame.Extended/Game1/Content/hills.png differ diff --git a/MonoGame.Extended/Game1/Content/read-me.md b/MonoGame.Extended/Game1/Content/read-me.md new file mode 100644 index 00000000..ef85d2a5 --- /dev/null +++ b/MonoGame.Extended/Game1/Content/read-me.md @@ -0,0 +1,3 @@ +## [Simple Hills Background](https://www.gamedevmarket.net/asset/simple-hills-background-1030/) + + hills.png diff --git a/MonoGame.Extended/Game1/Game1.cs b/MonoGame.Extended/Game1/Game1.cs index 7dcc6590..f31307eb 100644 --- a/MonoGame.Extended/Game1/Game1.cs +++ b/MonoGame.Extended/Game1/Game1.cs @@ -11,6 +11,7 @@ namespace Game1 private SpriteBatch _spriteBatch; private TextureRegion2D _textureRegion; private OrthographicCamera _camera; + private Texture2D _backgroundTexture; public Game1() { @@ -21,13 +22,17 @@ namespace Game1 protected override void Initialize() { - _camera = new OrthographicCamera(); + _camera = new OrthographicCamera + { + Origin = new Vector2(GraphicsDevice.Viewport.Width / 2f, GraphicsDevice.Viewport.Height / 2f) + }; base.Initialize(); } protected override void LoadContent() { _spriteBatch = new SpriteBatch(GraphicsDevice); + _backgroundTexture = Content.Load("hills"); var texture = Content.Load("shadedDark42"); _textureRegion = new TextureRegion2D(texture, 5, 5, 32, 32); @@ -39,14 +44,33 @@ namespace Game1 protected override void Update(GameTime gameTime) { + var deltaTime = (float) gameTime.ElapsedGameTime.TotalSeconds; var keyboardState = Keyboard.GetState(); var gamePadState = GamePad.GetState(PlayerIndex.One); if (gamePadState.Buttons.Back == ButtonState.Pressed || keyboardState.IsKeyDown(Keys.Escape)) Exit(); + var up = new Vector2(0, -250); + var right = new Vector2(250, 0); + + if (keyboardState.IsKeyDown(Keys.Q)) + _camera.Rotation -= deltaTime; + + if (keyboardState.IsKeyDown(Keys.W)) + _camera.Rotation += deltaTime; + if (keyboardState.IsKeyDown(Keys.Up)) - _camera.Position += new Vector2(-1, -1); + _camera.Position += up * deltaTime; + + if (keyboardState.IsKeyDown(Keys.Down)) + _camera.Position += -up * deltaTime; + + if (keyboardState.IsKeyDown(Keys.Left)) + _camera.Position += -right * deltaTime; + + if (keyboardState.IsKeyDown(Keys.Right)) + _camera.Position += right * deltaTime; base.Update(gameTime); } @@ -57,6 +81,7 @@ namespace Game1 var transformMatrix = _camera.CalculateTransformMatrix(); _spriteBatch.Begin(transformMatrix: transformMatrix); + _spriteBatch.Draw(_backgroundTexture, Vector2.Zero); _spriteBatch.Draw(_textureRegion, Vector2.Zero, Color.White); _spriteBatch.End(); diff --git a/MonoGame.Extended/Game1/Game1.csproj b/MonoGame.Extended/Game1/Game1.csproj index 8cce7b09..2fb3436d 100644 --- a/MonoGame.Extended/Game1/Game1.csproj +++ b/MonoGame.Extended/Game1/Game1.csproj @@ -55,6 +55,7 @@ + diff --git a/MonoGame.Extended/MonoGame.Extended/Camera.cs b/MonoGame.Extended/MonoGame.Extended/Camera.cs index 607a72f3..225c4d9d 100644 --- a/MonoGame.Extended/MonoGame.Extended/Camera.cs +++ b/MonoGame.Extended/MonoGame.Extended/Camera.cs @@ -1,5 +1,4 @@ using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace MonoGame.Extended {