From fec4d996d94b751767eadd965168b394d7405e96 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Thu, 19 Dec 2024 08:10:34 +0000 Subject: [PATCH] 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. --- fcore/player.sml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fcore/player.sml b/fcore/player.sml index 88ebc02..eb35548 100644 --- a/fcore/player.sml +++ b/fcore/player.sml @@ -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) =