Пример #1
0
        public virtual void Update(GameTime gameTime, KeyboardState keyboard, PlayerManager playerManager)
        {
            Rectangle playerRec = playerManager.BoundingBox;
            Rectangle playerBoun = playerManager.playerBounds;

            if (keyboard.IsKeyDown(Keys.Down) && playerRec.Y + playerRec.Height <= playerBoun.Y + playerBoun.Height)
                playerManager.down(gameTime.ElapsedGameTime.Milliseconds);
            if (keyboard.IsKeyDown(Keys.Up) && playerRec.Y >= 0)
                playerManager.up(gameTime.ElapsedGameTime.Milliseconds);
            if (keyboard.IsKeyDown(Keys.Right))
            {
                if (playerRec.X + playerRec.Width <= playerBoun.X + playerBoun.Width)
                   playerManager.right(gameTime.ElapsedGameTime.Milliseconds);
                playerManager.isFront = true;
            }
            if (keyboard.IsKeyDown(Keys.Left))
            {
                if (playerRec.X >= 40)
                   playerManager.left(gameTime.ElapsedGameTime.Milliseconds);
                playerManager.isFront = false;
            }
        }