progress towards letting enemy drop below platform if path to player is there

This commit is contained in:
2025-01-23 00:01:15 +00:00
parent 174a99a5a0
commit efbf0c7da9
2 changed files with 22 additions and 7 deletions

View File

@@ -194,6 +194,19 @@ struct
andalso (ey > platY andalso ey + Constants.jumpLimit >= platY)
end
fun canDrop (nextPlatform, platformTree, enemy) =
let
val {x = platX, y = platY, width = platW, ...} = nextPlatform
val platFinishX = platX + platW
val {x = eX, y = ey, yAxis = eyAxis, ...} = enemy
val standingOnPlat = standingOnArea (enemy, platformTree)
in
isBetween (platX, eX, platFinishX) andalso standingOnPlat
andalso ey < platY
end
(* get patches to help enemy move to nextPlatformID *)
fun getPathToNextPlatform
(nextPlatformID, platforms, platformTree, enemy, eID, pID, acc) =
@@ -203,13 +216,15 @@ struct
val {x = eX, y = ey, yAxis = eyAxis, ...} = enemy
val canJump = canJump (nextPlatform, platformTree, enemy)
val canDrop = canDrop (nextPlatform, platformTree, enemy)
in
if canJump then
case eyAxis of
ON_GROUND => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
| FALLING => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
| _ => acc
else if canDrop then
EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: acc
else
acc
end

View File

@@ -153,7 +153,7 @@ struct
(x, y, size, size, 0, 0, ww, wh, 0, platformTree)
val acc = getPlatformPatches (yAxis, platforms, platCollisions, [])
val acc =
val acc =
case yAxis of
DROP_BELOW_PLATFORM =>
(* if we dropped below platform before
@@ -162,11 +162,11 @@ struct
* then set new yAxis to FALLING
* so we do not drop below any platforms again
* *)
if QuadTree.hasCollisionAt (x, y, size, size, 0, 0, ww, wh, ~1,
platformTree)
then
Fn.W_Y_AXIS FALLING :: acc
else acc
if
QuadTree.hasCollisionAt
(x, y, size, size, 0, 0, ww, wh, ~1, platformTree)
then acc
else Fn.W_Y_AXIS FALLING :: acc
| _ => acc
val wallCollisions = QuadTree.getCollisionSides