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; } }
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; } }