fix bug. Bug was: if player jumps on platform while holding up, and walks off platform while still holding up, the player has the same 'y' coordinate, floating in the air when gravity should be applied. Fixed by applying gravity in the onJumpPressed function, when jumpPressed variable is true.

This commit is contained in:
2024-12-19 08:10:34 +00:00
parent 65ce098a71
commit fec4d996d9

View File

@@ -137,7 +137,7 @@ struct
end
in
checkEnemies
( FALLING, STAY_STILL, x, y, health, false, newRecoil
( FALLING, STAY_STILL, x, y, health, jumpPressed, newRecoil
, tl, platCollisions, wallCollisions, game
)
end
@@ -273,7 +273,12 @@ struct
* is on the ground. *)
fun onJumpPressed (prevAxis, jumpPressed) =
case prevAxis of
ON_GROUND => if jumpPressed then prevAxis else JUMPING 0
ON_GROUND =>
if jumpPressed then
(* apply gravity *)
FALLING
else
JUMPING 0
| _ => prevAxis
fun handleInput (game: game_type, input, recoil) =