attempt at coding functionality to jump/drop when platform is to the right and not overlapping with current platform

This commit is contained in:
2025-01-25 08:34:05 +00:00
parent d8af1da6de
commit c8f56f3077

View File

@@ -313,11 +313,35 @@ struct
(* platform is below or at same y coordinat as enemy
* so might possibly require dropping below rather than jumping. *)
let
(* check if we can get to next platform without jumping.
* If we can, then simply move rightwards
* and possibly drop below platform.
* Else, jump and move rightwards *)
val yDiff = ey - platY
in
if yDiff >= xDiff then
(* can reach next platform by simply dropping and moving right *)
EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: EnemyPatch.W_X_AXIS
MOVE_RIGHT :: acc
else
let
val jumpAmt =
case eyAxis of
JUMPING amt => amt
| _ => 0
val apexY = ey - (Constants.jumpLimit - jumpAmt)
val yDiff = apexY - platY
in
if yDiff >= xDiff then
(* can reach if we jump and move right *)
EnemyPatch.W_Y_AXIS (JUMPING 0) :: EnemyPatch.W_X_AXIS
MOVE_RIGHT :: acc
else
(* cannot reach yet so move right until we can *)
EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
end
end
end
(* get patches to help enemy move to nextPlatformID *)
fun getPathToNextPlatform