public void Update(GameTime gameTime) { fireBallCount = Game.objects.Count; CurrentState = Keyboard.GetState(); Keys[] keys = CurrentState.GetPressedKeys(); if (CurrentState.IsKeyUp(Keys.Z)) { JumpKeyWasPressed = false; } if (CurrentState.IsKeyUp(Keys.X)) { FireballWasPressed = false; } foreach (Keys key in keys) { if (RegisteredKeys.Contains(key)) { Transition(key, gameTime); if (key == Keys.Z) { if (!JumpKeyWasPressed) { DebugModeDelay(key); JumpKeyWasPressed = true; } else if (Game.Mario.Physics.YVelocity < 0) { Game.Mario.Physics.YVelocity -= .1;//hackish probably change. } } if (key == Keys.X && (CurrentState.IsKeyDown(Keys.Left) || CurrentState.IsKeyDown(Keys.Right))) { DebugModeDelay(key); } else if (key != Keys.Z && key != Keys.X) { DebugModeDelay(key); } if (key == Keys.X && !FireballWasPressed && FireBallLimit - fireBallCount > 0) { ICommand fb = new MarioFireBallCommand(Game); fb.Execute(); FireballWasPressed = true; } } } PreviousState = CurrentState; }
public void Update(GameTime gameTime) { fireBallCount = Game.objects.Count; CurrentState = GamePad.GetState(PlayerIndex.One); PressedButtons = GetPressedButtons(CurrentState); if (CurrentState.Buttons.A == ButtonState.Released) { JumpKeyWasPressed = false; } if (CurrentState.Buttons.X == ButtonState.Released) { FireballWasPressed = false; } foreach (Buttons button in PressedButtons) { Transition(button, gameTime); if (button == Buttons.A) { if (!JumpKeyWasPressed) { DebugModeDelay(button); JumpKeyWasPressed = true; } else if (Game.Mario.Physics.YVelocity < 0) { Game.Mario.Physics.YVelocity -= .1; //hackish probably change. } } if (button == Buttons.X && (CurrentState.DPad.Left == ButtonState.Pressed || CurrentState.DPad.Right == ButtonState.Pressed)) { DebugModeDelay(button); } else if (button != Buttons.A && button != Buttons.X) { DebugModeDelay(button); } if (button == Buttons.X && !FireballWasPressed && FireBallLimit - fireBallCount > 0) { ICommand fb = new MarioFireBallCommand(Game); fb.Execute(); FireballWasPressed = true; } } PreviousState = CurrentState; }