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