예제 #1
0
        private void MovePlayer()
        {
            var velocity = new Vector2();

            if (InputHelper.AnyKeyPressed(KeyList.A, KeyList.Left))
            {
                velocity.x -= 1;
            }

            if (InputHelper.AnyKeyPressed(KeyList.D, KeyList.Right))
            {
                velocity.x += 1;
            }

            if (InputHelper.AnyKeyPressed(KeyList.W, KeyList.Up))
            {
                velocity.y -= 1;
            }

            if (InputHelper.AnyKeyPressed(KeyList.S, KeyList.Down))
            {
                velocity.y += 1;
            }

            velocity = velocity * _speed;
            MoveAndSlide(velocity);

            EmitSignal(nameof(PositionChanged), Position);
        }
예제 #2
0
 public override void Update(GameTime gameTime, InputHelper input)
 {
     if (_gamemanager.Game.IsActive)
     {
         if (input.AnyKeyPressed(true))
         {
             _gamemanager.SwitchState(GameState.MainMenuState);
         }
     }
 }
예제 #3
0
 public override void Update(GameTime gameTime, InputHelper input)
 {
     if (!_introstarted)
     {
         _gamemanager.Audiomanager.PlaySong(_introsong, false);
         _introstarted = true;
     }
     if (_gamemanager.Game.IsActive)
     {
         if (input.AnyKeyPressed(true))
         {
             _gamemanager.Audiomanager.StopPlaying();
             _gamemanager.SwitchState(GameState.MainMenuState);
         }
     }
 }