Example #1
0
        public void Update(Game1 game, KeyboardState currentState, KeyboardState lastState, GameTime gameTime)
        {
            if (currentState.IsKeyDown(Keys.Left))
            {
                Move(-5, 0);
            }
            if (currentState.IsKeyDown(Keys.Right))
            {
                Move(5, 0);
            }
            if (currentState.IsKeyDown(Keys.Space) && !lastState.IsKeyDown(Keys.Space))
            {
                if (game.GetEntites(x => x.Name == "bullet") == null)

                {
                    game.AddEntity(new Bullet(game, bulletSprite, _x + 25, _y - 30));
                }
            }

            if (_x > maxX)
            {
                _x = maxX;
            }
            if (_x < 0)
            {
                _x = 0;
            }

            if (currentCooldown > 0)
            {
                currentCooldown--;
            }
        }