|
|
@ -29,7 +29,7 @@ namespace Jumpy { |
|
|
|
this.texture = texture; |
|
|
|
} |
|
|
|
|
|
|
|
public void Update(GameTime gameTime, GamePadState gamePad) { |
|
|
|
public void Update(GameTime time, GamePadState gamePad) { |
|
|
|
if (gamePad.Buttons.A == ButtonState.Pressed && airState == AirState.Ground) { |
|
|
|
pose = Pose.Jumping; |
|
|
|
airState = AirState.Jumping; |
|
|
@ -47,11 +47,11 @@ namespace Jumpy { |
|
|
|
if (gamePad.DPad.Left == ButtonState.Pressed || leftStick.X < -0.5) { |
|
|
|
facing = Facing.Left; |
|
|
|
pose = Pose.Walking; |
|
|
|
position.X -= (int) (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds); |
|
|
|
position.X -= (int) (moveSpeed * (float) time.ElapsedGameTime.TotalSeconds); |
|
|
|
} else if (gamePad.DPad.Right == ButtonState.Pressed || leftStick.X > 0.5) { |
|
|
|
facing = Facing.Right; |
|
|
|
pose = Pose.Walking; |
|
|
|
position.X += (int) (moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds); |
|
|
|
position.X += (int) (moveSpeed * (float) time.ElapsedGameTime.TotalSeconds); |
|
|
|
} else if (gamePad.DPad.Down == ButtonState.Pressed || leftStick.Y < -0.5) { |
|
|
|
pose = Pose.Crouching; |
|
|
|
} else if (gamePad.DPad.Up == ButtonState.Pressed || leftStick.Y > 0.5) { |
|
|
@ -61,16 +61,16 @@ namespace Jumpy { |
|
|
|
} |
|
|
|
|
|
|
|
if (jumpTime > 0) { |
|
|
|
jumpTime -= gameTime.ElapsedGameTime.TotalSeconds; |
|
|
|
jumpTime -= time.ElapsedGameTime.TotalSeconds; |
|
|
|
} |
|
|
|
if (swordSwingTime > 0) { |
|
|
|
swordSwingTime -= gameTime.ElapsedGameTime.TotalSeconds; |
|
|
|
swordSwingTime -= time.ElapsedGameTime.TotalSeconds; |
|
|
|
pose = Pose.SwordSwing; |
|
|
|
} |
|
|
|
|
|
|
|
if (airState == AirState.Jumping) { |
|
|
|
position.Y += (int) (ySpeed * gameTime.ElapsedGameTime.TotalSeconds); |
|
|
|
ySpeed += gravity * (float) gameTime.ElapsedGameTime.TotalSeconds; |
|
|
|
position.Y += (int) (ySpeed * time.ElapsedGameTime.TotalSeconds); |
|
|
|
ySpeed += gravity * (float) time.ElapsedGameTime.TotalSeconds; |
|
|
|
if (position.Y > groundLevel) { |
|
|
|
position.Y = groundLevel; |
|
|
|
ySpeed = 0; |
|
|
|