when enemy jumps or drops without needing to move horizontally to reach platform, tell enemy to stay still so we don't risk falling off platform

This commit is contained in:
2025-01-29 02:23:44 +00:00
parent 296e120d12
commit e2f5f18089
2 changed files with 39 additions and 29 deletions

View File

@@ -176,10 +176,16 @@ struct
isBetween (platX, ecx, platFinishX)
then
(* can jump from same position enemy is at *)
let
(* since we want to jump vertically and not risk falling off by
* jumping + moving either left or right, make enemy stay still *)
val acc = EnemyPatch.W_X_AXIS STAY_STILL :: acc
in
case eyAxis of
ON_GROUND => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
| FALLING => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
| _ => acc
end
else (* have to travel either left or right before jumping *) if
ecx < platX
then
@@ -219,10 +225,14 @@ struct
isBetween (platX, ecx, platFinishX)
then
(* can jump from same position enemy is at *)
let
val acc = EnemyPatch.W_X_AXIS STAY_STILL :: acc
in
case eyAxis of
ON_GROUND => EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: acc
| FALLING => EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: acc
| _ => acc
end
else (* have to travel either left or right before jumping *) if
ecx < platX
then
@@ -420,6 +430,10 @@ struct
(* if only one side in x direction overlaps with platform,
* then move enemy left/right to make them fully overlap with platform *)
fun getHorizontalLandingPatches (enemy, nextPlatform, acc) =
case #xAxis enemy of
STAY_STILL =>
acc
| _ =>
let
val {x = px, width = pw, ...} = nextPlatform
val pfx = px + pw

View File

@@ -320,10 +320,6 @@ struct
let
val player = #player game
val _ = print
("(playerX, playerY) = (" ^ Int.toString (#x player) ^ ", "
^ Int.toString (#y player) ^ ")\n")
val patches = getProjectilePatches player
val player = PlayerPatch.withPatches (player, patches)