implement function to trace drop (while moving right)
This commit is contained in:
@@ -244,14 +244,20 @@ struct
|
||||
end
|
||||
|
||||
fun getMoveRightPatches (nextPlatform, enemy, platformTree, acc) =
|
||||
if TraceJump.traceRightJump (enemy, #id nextPlatform, platformTree, nextPlatform) then
|
||||
(* important to check for drop first because path of traceRightJump includes
|
||||
* descent of jump/drop.
|
||||
* So, if we check for jump first, we would always jump before dropping
|
||||
* even if jumping is not necessary. *)
|
||||
if TraceJump.traceRightDrop (enemy, #id nextPlatform, platformTree) then
|
||||
EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM ::
|
||||
EnemyPatch.W_X_AXIS MOVE_RIGHT ::
|
||||
acc
|
||||
else if TraceJump.traceRightJump (enemy, #id nextPlatform, platformTree) then
|
||||
if standingOnArea (enemy, platformTree) then
|
||||
EnemyPatch.W_Y_AXIS (JUMPING 0) :: EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
|
||||
else
|
||||
EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
|
||||
else
|
||||
(* placeholder: should check if we can move to the next platform while
|
||||
* dropping *)
|
||||
EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
|
||||
|
||||
fun getMoveLeftPatches (nextPlatform, enemy, platformTree, acc) =
|
||||
|
||||
@@ -27,7 +27,16 @@ struct
|
||||
traceRightJumpDescent (nextX, nextY, nextPlatID, platTree)
|
||||
end
|
||||
|
||||
fun traceRightJumpAscent (x, y, remainingJump, nextPlatID, platTree, nextPlatform) =
|
||||
fun traceRightDrop (enemy, nextPlatID, platTree) =
|
||||
let
|
||||
open GameType
|
||||
val {x, y, ...}: enemy = enemy
|
||||
val x = x - Constants.enemySize
|
||||
in
|
||||
traceRightJumpDescent (x, y, nextPlatID, platTree)
|
||||
end
|
||||
|
||||
fun traceRightJumpAscent (x, y, remainingJump, nextPlatID, platTree) =
|
||||
if remainingJump >= Constants.jumpLimit then
|
||||
traceRightJumpDescent (x, y, nextPlatID, platTree)
|
||||
else
|
||||
@@ -42,22 +51,23 @@ struct
|
||||
val nextJump = remainingJump + Constants.moveEnemyBy
|
||||
in
|
||||
shouldJumpRight orelse
|
||||
traceRightJumpAscent (nextX, nextY, nextJump, nextPlatID, platTree, nextPlatform)
|
||||
traceRightJumpAscent (nextX, nextY, nextJump, nextPlatID, platTree)
|
||||
end
|
||||
|
||||
fun traceRightJump (enemy, nextPlatID, platTree, nextPlat) =
|
||||
fun traceRightJump (enemy, nextPlatID, platTree) =
|
||||
let
|
||||
open GameType
|
||||
val {x, y, ...}: enemy = enemy
|
||||
val x = x - Constants.enemySize
|
||||
in
|
||||
if EnemyPhysics.standingOnArea (x, y, platTree) then
|
||||
traceRightJumpAscent (x, y, 0, nextPlatID, platTree, nextPlat)
|
||||
traceRightJumpAscent (x, y, 0, nextPlatID, platTree)
|
||||
else
|
||||
case #yAxis enemy of
|
||||
JUMPING amt =>
|
||||
traceRightJumpAscent (x, y, amt, nextPlatID, platTree, nextPlat)
|
||||
traceRightJumpAscent (x, y, amt, nextPlatID, platTree)
|
||||
| ON_GROUND =>
|
||||
traceRightJumpAscent (x, y, 0, nextPlatID, platTree, nextPlat)
|
||||
traceRightJumpAscent (x, y, 0, nextPlatID, platTree)
|
||||
| FALLING =>
|
||||
traceRightJumpDescent (x, y, nextPlatID, platTree)
|
||||
| DROP_BELOW_PLATFORM =>
|
||||
|
||||
Reference in New Issue
Block a user