|
|
@ -29,9 +29,8 @@ namespace Jumpy { |
|
|
|
this.texture = texture; |
|
|
|
} |
|
|
|
|
|
|
|
public void Update(GameTime time, History<GamePadState> gamePadHistory) { |
|
|
|
GamePadState gamePad = gamePadHistory[0]; |
|
|
|
if (gamePad.Buttons.A == ButtonState.Pressed && airState == AirState.Ground) { |
|
|
|
public void Update(GameTime time, History<GamePadState> gamePad) { |
|
|
|
if (gamePad[0].IsButtonDown(Buttons.A) && airState == AirState.Ground) { |
|
|
|
pose = Pose.Jumping; |
|
|
|
airState = AirState.Jumping; |
|
|
|
jumpTime = 0.5; |
|
|
@ -39,23 +38,23 @@ namespace Jumpy { |
|
|
|
return; |
|
|
|
} |
|
|
|
// TODO: only swing the sword if button newly pressed (no turbosword)
|
|
|
|
if (gamePad.Buttons.X == ButtonState.Pressed && swordSwingTime <= 0) { |
|
|
|
if (gamePad[0].IsButtonDown(Buttons.X) && swordSwingTime <= 0) { |
|
|
|
pose = Pose.SwordSwing; |
|
|
|
swordSwingTime = 0.3; |
|
|
|
return; |
|
|
|
} |
|
|
|
Vector2 leftStick = gamePad.ThumbSticks.Left; |
|
|
|
if (gamePad.DPad.Left == ButtonState.Pressed || leftStick.X < -0.5) { |
|
|
|
Vector2 leftStick = gamePad[0].ThumbSticks.Left; |
|
|
|
if (gamePad[0].IsButtonDown(Buttons.DPadLeft) || leftStick.X < -0.5) { |
|
|
|
facing = Facing.Left; |
|
|
|
pose = Pose.Walking; |
|
|
|
position.X -= (int) (moveSpeed * (float) time.ElapsedGameTime.TotalSeconds); |
|
|
|
} else if (gamePad.DPad.Right == ButtonState.Pressed || leftStick.X > 0.5) { |
|
|
|
} else if (gamePad[0].IsButtonDown(Buttons.DPadRight) || leftStick.X > 0.5) { |
|
|
|
facing = Facing.Right; |
|
|
|
pose = Pose.Walking; |
|
|
|
position.X += (int) (moveSpeed * (float) time.ElapsedGameTime.TotalSeconds); |
|
|
|
} else if (gamePad.DPad.Down == ButtonState.Pressed || leftStick.Y < -0.5) { |
|
|
|
} else if (gamePad[0].IsButtonDown(Buttons.DPadDown) || leftStick.Y < -0.5) { |
|
|
|
pose = Pose.Crouching; |
|
|
|
} else if (gamePad.DPad.Up == ButtonState.Pressed || leftStick.Y > 0.5) { |
|
|
|
} else if (gamePad[0].IsButtonDown(Buttons.DPadUp) || leftStick.Y > 0.5) { |
|
|
|
pose = Pose.Stretching; |
|
|
|
} else { |
|
|
|
pose = Pose.Standing; |
|
|
|