refactor physics.sml so that we always set plat ID of player/enemy, when player or enemy stands on new platform, and make changes to enemy-behaviour.sml in calculation to jump to the top-right after testing
This commit is contained in:
@@ -295,13 +295,14 @@ struct
|
||||
* but if y is lower, that means we can reach if we jump at this point
|
||||
* so we should simply move rightwards.
|
||||
* *)
|
||||
val xyDiff = apexY - xDiff
|
||||
val yDiff = platY - apexY
|
||||
in
|
||||
if xyDiff >= 0 then
|
||||
if yDiff > xDiff then
|
||||
let
|
||||
val acc =
|
||||
case eyAxis of
|
||||
ON_GROUND => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
|
||||
| FALLING => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
|
||||
| _ => acc
|
||||
in
|
||||
EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
|
||||
@@ -378,7 +379,16 @@ struct
|
||||
let
|
||||
(* todo: possibly get pID and eID of player/enemy in a different way *)
|
||||
val pID = getPlatformBelowPlayer (player, platformTree, platforms)
|
||||
val pID =
|
||||
if pID = ~1 then
|
||||
#platID player
|
||||
else pID
|
||||
|
||||
val eID = getPlatformBelowEnemy (enemy, platformTree, platforms)
|
||||
val eID =
|
||||
if eID = ~1 then
|
||||
#platID enemy
|
||||
else eID
|
||||
in
|
||||
if eID = pID then
|
||||
EnemyPatch.W_Y_AXIS FALLING :: acc
|
||||
|
||||
@@ -168,7 +168,7 @@ struct
|
||||
|
||||
val plat1 = {id = 1, x = 155, y = 911, width = 199}
|
||||
val plat2 = {id = 2, x = 355, y = 759, width = 555}
|
||||
val plat3 = {id = 3, x = 355, y = 659, width = 555}
|
||||
val plat3 = {id = 3, x = 355, y = 659, width = 111}
|
||||
val plat4 = {id = 4, x = 155, y = 855, width = 99}
|
||||
val plat5 = {id = 5, x = 155, y = 811, width = 199}
|
||||
val plat6 = {id = 6, x = 155, y = 710, width = 199}
|
||||
|
||||
@@ -19,6 +19,7 @@ sig
|
||||
val W_X: int -> patch
|
||||
val W_Y: int -> patch
|
||||
val W_Y_AXIS: GameType.y_axis -> patch
|
||||
val W_PLAT_ID: int -> patch
|
||||
end
|
||||
|
||||
functor MakePhysics(Fn: PHYSICS_INPUT) =
|
||||
@@ -200,8 +201,14 @@ struct
|
||||
|
||||
val wallCollisions = QuadTree.getCollisionSides
|
||||
(x, y, size, size, 0, 0, ww, wh, 0, wallTree)
|
||||
val acc = getWallPatches (walls, wallCollisions, acc)
|
||||
|
||||
val standPlatID = standingOnAreaID (x, y, platformTree)
|
||||
in
|
||||
getWallPatches (walls, wallCollisions, acc)
|
||||
if standPlatID <> ~1 then
|
||||
Fn.W_PLAT_ID standPlatID :: acc
|
||||
else
|
||||
acc
|
||||
end
|
||||
end
|
||||
|
||||
@@ -228,6 +235,7 @@ structure PlayerPhysics =
|
||||
val W_X = PlayerPatch.W_X
|
||||
val W_Y = PlayerPatch.W_Y
|
||||
val W_Y_AXIS = PlayerPatch.W_Y_AXIS
|
||||
val W_PLAT_ID = PlayerPatch.W_PLAT_ID
|
||||
end)
|
||||
|
||||
structure EnemyPhysics =
|
||||
@@ -253,4 +261,5 @@ structure EnemyPhysics =
|
||||
val W_X = EnemyPatch.W_X
|
||||
val W_Y = EnemyPatch.W_Y
|
||||
val W_Y_AXIS = EnemyPatch.W_Y_AXIS
|
||||
val W_PLAT_ID = EnemyPatch.W_PLAT_ID
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user