public void Move(LevelMap levelMap, Texture2D tex) { KeyboardState kbState = Keyboard.GetState(); if (kbState.IsKeyDown(Keys.Right)) { playerPosition.X += playerSpeed; levelMap.CheckBoundaries(new Vector2(playerPosition.X + playerSpeed, playerPosition.Y), this, tex); } if (kbState.IsKeyDown(Keys.Left)) { playerPosition.X -= playerSpeed; levelMap.CheckBoundaries(new Vector2(playerPosition.X - playerSpeed, playerPosition.Y), this, tex); } if (kbState.IsKeyDown(Keys.Down)) { playerPosition.Y += playerSpeed; levelMap.CheckBoundaries(new Vector2(playerPosition.X, playerPosition.Y + playerSpeed), this, tex); } if (kbState.IsKeyDown(Keys.Up)) { playerPosition.Y -= playerSpeed; levelMap.CheckBoundaries(new Vector2(playerPosition.X, playerPosition.Y - playerSpeed), this, tex); } if (kbState.IsKeyDown(Keys.Space) && Game1.isHorseColidate == true) { Environment.Exit(1); } playerPositionCenter = new Vector2(playerPosition.X + spriteTexture.Width / 2, playerPosition.Y + spriteTexture.Height / 2); }
protected override void Initialize() { base.Initialize(); sprite = new Sprite(); levelMap = new LevelMap(); sprite.playerPosition = new Vector2(0, 0); Globals.graphics.PreferredBackBufferHeight = Globals.screenHeight; Globals.graphics.PreferredBackBufferWidth = Globals.screenWidth; Globals.graphics.ApplyChanges(); }