Beispiel #1
0
        private void UpdateDebugInput()
        {
            KeyboardState keyboardState = Keyboard.GetState();
            KeyboardConfiguration kb = new KeyboardConfiguration(keyboardState);

            if (kb.IsKeyPressed(ActionKey.ToggleDiagnosticMode, oldState))
            {
                Config.Diagnostic = !Config.Diagnostic;
            }

            if (Config.Diagnostic) // debug mode only available in diagnostic configuration.
            {
                if (kb.IsKeyPressed(ActionKey.ToggleDebugMode, oldState))
                {
                    debugMode = !debugMode;
                }

                if (kb.IsKeyPressed(ActionKey.UpdateInNextFrame, oldState))
                {
                    debugMode = true;
                    updateInNextFrame = true;
                }
            }
            oldState = keyboardState;
        }
Beispiel #2
0
        public void UpdateInput(GameTime gameTime)
        {
            KeyboardState keyboardState = Keyboard.GetState();
            KeyboardConfiguration kb = new KeyboardConfiguration(keyboardState);

            if (kb.IsKeyPressed(ActionKey.ToggleMusic, oldState))
            {
                if (MediaPlayer.State == MediaState.Stopped)
                {
                    PlayRandomSong();
                }
                else
                {
                    stopping = true;
                    MediaPlayer.Stop();
                }
            }

            oldState = keyboardState;
        }
Beispiel #3
0
        private void PausedInput()
        {
            if (!gameOver)
            {
                return;
            }
            KeyboardState keyboardState = Keyboard.GetState();
            KeyboardConfiguration kb = new KeyboardConfiguration(keyboardState);

            if (kb.IsKeyPressed(ActionKey.Resume, oldState))
            {
                gameOver = false;
                Restart();
            }
        }
Beispiel #4
0
 private void UpdateMovementSurfaced(KeyboardConfiguration kb, GameTime gameTime)
 {
     if (kb.IsKeyDown(ActionKey.Jump))
     {
         JumpEffects();
         Speed.Y = MagicNumbers.JumpSpeed;
         lastJumpStarted = gameTime.TotalGameTime;
         jumpStartPosition = Position + MagicNumbers.FallEffect;
     }
     else if (kb.IsKeyDown(ActionKey.Right))
     {
         Direction = Direction.Right;
     }
     else if (kb.IsKeyDown(ActionKey.Left))
     {
         Direction = Direction.Left;
     }
     else
     {
         Direction = Direction.None;
     }
 }
Beispiel #5
0
        private void UpdateMovementAirborne(KeyboardConfiguration kb, GameTime gameTime)
        {
            if (kb.IsKeyDown(ActionKey.Jump))
            {
                if (!lastJumpStarted.HasValue) // sanity.
                {
                    return;
                }
                if (gameTime.TotalGameTime - lastJumpStarted.Value < MagicNumbers.JumpWindow)
                {
                    Speed.Y = MagicNumbers.JumpSpeed / 2;
                }
            }

            if (kb.IsKeyDown(ActionKey.Right))
            {
                Direction = Direction.Right;
            }
            else if (kb.IsKeyDown(ActionKey.Left))
            {
                Direction = Direction.Left;
            }
            else
            {
                Direction = Direction.None;
            }
        }
Beispiel #6
0
        private void UpdateMovement(GameTime gameTime)
        {
            var kb = new KeyboardConfiguration(keyboardState);

            if (Config.Diagnostic)
            {
                if (kb.IsKeyPressed(ActionKey.Suicide, oldState))
                {
                    Die();
                }
                oldState = keyboardState;
            }

            if (State == HitBoxState.Surfaced)
            {
                UpdateMovementSurfaced(kb, gameTime);
            }
            else if (State == HitBoxState.Airborne)
            {
                UpdateMovementAirborne(kb, gameTime);
            }
        }