when tracing left jump, consider the enemy's 'x' coordinate to be the leftmost point of the enemy
This commit is contained in:
@@ -163,7 +163,6 @@ struct
|
|||||||
let
|
let
|
||||||
(* since we want to jump vertically and not risk falling off by
|
(* since we want to jump vertically and not risk falling off by
|
||||||
* jumping + moving either left or right, make enemy stay still *)
|
* jumping + moving either left or right, make enemy stay still *)
|
||||||
val acc = EnemyPatch.W_X_AXIS STAY_STILL :: acc
|
|
||||||
in
|
in
|
||||||
case eyAxis of
|
case eyAxis of
|
||||||
ON_GROUND => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
|
ON_GROUND => EnemyPatch.W_Y_AXIS (JUMPING 0) :: acc
|
||||||
@@ -210,7 +209,6 @@ struct
|
|||||||
then
|
then
|
||||||
(* can jump from same position enemy is at *)
|
(* can jump from same position enemy is at *)
|
||||||
let
|
let
|
||||||
val acc = EnemyPatch.W_X_AXIS STAY_STILL :: acc
|
|
||||||
in
|
in
|
||||||
case eyAxis of
|
case eyAxis of
|
||||||
ON_GROUND => EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: acc
|
ON_GROUND => EnemyPatch.W_Y_AXIS DROP_BELOW_PLATFORM :: acc
|
||||||
@@ -287,51 +285,13 @@ struct
|
|||||||
(* if only one side in x direction overlaps with platform,
|
(* if only one side in x direction overlaps with platform,
|
||||||
* then move enemy left/right to make them fully overlap with platform *)
|
* then move enemy left/right to make them fully overlap with platform *)
|
||||||
fun getHorizontalLandingPatches (enemy, nextPlatform, acc) =
|
fun getHorizontalLandingPatches (enemy, nextPlatform, acc) =
|
||||||
case #xAxis enemy of
|
|
||||||
STAY_STILL => acc
|
|
||||||
| _ =>
|
|
||||||
let
|
|
||||||
val {x = px, width = pw, ...} = nextPlatform
|
|
||||||
val pfx = px + pw
|
|
||||||
|
|
||||||
val {x = ex, ...} = enemy
|
|
||||||
val efx = ex + Constants.enemySize
|
|
||||||
in
|
|
||||||
if isBetween (px, ex, pfx) andalso isBetween (px, efx, pfx) then
|
|
||||||
acc
|
acc
|
||||||
else
|
|
||||||
let
|
|
||||||
val startDiff = abs (px - ex)
|
|
||||||
val endDiff = abs (pfx - efx)
|
|
||||||
in
|
|
||||||
if startDiff > endDiff then EnemyPatch.W_X_AXIS MOVE_LEFT :: acc
|
|
||||||
else EnemyPatch.W_X_AXIS MOVE_RIGHT :: acc
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
fun getFallingPatches (enemy, newPlatformID, platforms, acc) =
|
fun getFallingPatches (enemy, newPlatformID, platforms, acc) =
|
||||||
let
|
|
||||||
val nextPlatform = Platform.find (newPlatformID, platforms)
|
|
||||||
val acc = getHorizontalLandingPatches (enemy, nextPlatform, acc)
|
|
||||||
in
|
|
||||||
EnemyPatch.W_NEXT_PLAT_ID ~1 :: acc
|
EnemyPatch.W_NEXT_PLAT_ID ~1 :: acc
|
||||||
end
|
|
||||||
|
|
||||||
fun getJumpLandingPatches (enemy, nextPlatformID, platforms, acc) =
|
fun getJumpLandingPatches (enemy, nextPlatformID, platforms, acc) =
|
||||||
let
|
|
||||||
val nextPlatform = Platform.find (nextPlatformID, platforms)
|
|
||||||
val {y = py, ...} = nextPlatform
|
|
||||||
|
|
||||||
val {y = ey, ...} = enemy
|
|
||||||
|
|
||||||
val acc = getHorizontalLandingPatches (enemy, nextPlatform, acc)
|
|
||||||
in
|
|
||||||
if ey < py - 65 then
|
|
||||||
(* set to falling *)
|
|
||||||
EnemyPatch.W_NEXT_PLAT_ID ~1 :: EnemyPatch.W_Y_AXIS FALLING :: acc
|
|
||||||
else
|
|
||||||
acc
|
acc
|
||||||
end
|
|
||||||
|
|
||||||
fun getLandingPatches (newPlatformID, platforms, enemy, acc) =
|
fun getLandingPatches (newPlatformID, platforms, enemy, acc) =
|
||||||
case #yAxis enemy of
|
case #yAxis enemy of
|
||||||
@@ -356,12 +316,8 @@ struct
|
|||||||
fun getFollowPatches
|
fun getFollowPatches
|
||||||
(player: player, enemy, wallTree, platformTree, platforms, acc) =
|
(player: player, enemy, wallTree, platformTree, platforms, acc) =
|
||||||
let
|
let
|
||||||
(* todo: possibly get pID and eID of player/enemy in a different way *)
|
|
||||||
val pID = #platID player
|
val pID = #platID player
|
||||||
|
val eID = #platID enemy
|
||||||
val eID = getPlatformBelowEnemy (enemy, platformTree, platforms)
|
|
||||||
val eID = if eID = ~1 then #platID enemy else eID
|
|
||||||
|
|
||||||
in
|
in
|
||||||
if eID = ~1 orelse pID = ~1 then
|
if eID = ~1 orelse pID = ~1 then
|
||||||
(* without checking that neither of these are ~1
|
(* without checking that neither of these are ~1
|
||||||
|
|||||||
@@ -168,25 +168,14 @@ struct
|
|||||||
val walls = Vector.fromList [wall1, wall2, wall3]
|
val walls = Vector.fromList [wall1, wall2, wall3]
|
||||||
val wallTree = Wall.generateTree walls
|
val wallTree = Wall.generateTree walls
|
||||||
|
|
||||||
val plat1 = {id = 1, x = 111, y = 711, width = 199}
|
val plat1 = {id = 1, x = 255, y = 855, width = 199}
|
||||||
val plat2 = {id = 2, x = 355, y = 759, width = 555}
|
val plat2 = {id = 2, x = 750, y = 855, width = 199}
|
||||||
val plat3 = {id = 3, x = 955, y = 659, width = 111}
|
val plat3 = {id = 3, x = 399, y = 755, width = 399}
|
||||||
val plat4 = {id = 4, x = 455, y = 855, width = 99}
|
val plat4 = {id = 4, x = 255, y = 655, width = 199}
|
||||||
val plat5 = {id = 5, x = 555, y = 811, width = 199}
|
val plat5 = {id = 5, x = 750, y = 655, width = 199}
|
||||||
val plat6 = {id = 6, x = 655, y = 710, width = 199}
|
val plat6 = {id = 6, x = 171, y = 555, width = 99}
|
||||||
val plat7 = {id = 7, x = 701, y = 855, width = 99}
|
val plat7 = {id = 7, x = 934, y = 555, width = 99}
|
||||||
val plat8 = {id = 8, x = 970, y = 815, width = 303}
|
val plat8 = {id = 8, x = 399, y = 555, width = 399}
|
||||||
val plat9 = {id = 9, x = 959, y = 705, width = 303}
|
|
||||||
val plat10 = {id = 10, x = 970, y = 759, width = 303}
|
|
||||||
val plat11 = {id = 11, x = 970, y = 595, width = 303}
|
|
||||||
val plat12 = {id = 12, x = 959, y = 535, width = 303}
|
|
||||||
val plat13 = {id = 13, x = 970, y = 495, width = 303}
|
|
||||||
val plat14 = {id = 14, x = 1000, y = 415, width = 303}
|
|
||||||
val plat15 = {id = 15, x = 1000, y = 335, width = 303}
|
|
||||||
val plat16 = {id = 16, x = 1000, y = 295, width = 303}
|
|
||||||
val plat17 = {id = 17, x = 855, y = 599, width = 199}
|
|
||||||
val plat18 = {id = 18, x = 755, y = 499, width = 199}
|
|
||||||
val plat19 = {id = 19, x = 655, y = 399, width = 199}
|
|
||||||
val platforms = Vector.fromList
|
val platforms = Vector.fromList
|
||||||
[ plat1
|
[ plat1
|
||||||
, plat2
|
, plat2
|
||||||
@@ -196,17 +185,6 @@ struct
|
|||||||
, plat6
|
, plat6
|
||||||
, plat7
|
, plat7
|
||||||
, plat8
|
, plat8
|
||||||
, plat9
|
|
||||||
, plat10
|
|
||||||
, plat11
|
|
||||||
, plat12
|
|
||||||
, plat13
|
|
||||||
, plat14
|
|
||||||
, plat15
|
|
||||||
, plat16
|
|
||||||
, plat17
|
|
||||||
, plat18
|
|
||||||
, plat19
|
|
||||||
]
|
]
|
||||||
val platformTree = Platform.generateTree platforms
|
val platformTree = Platform.generateTree platforms
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ struct
|
|||||||
fun traceLeftJump (enemy: GameType.enemy, nextPlatID, platTree) =
|
fun traceLeftJump (enemy: GameType.enemy, nextPlatID, platTree) =
|
||||||
let
|
let
|
||||||
val {x, y, ...} = enemy
|
val {x, y, ...} = enemy
|
||||||
val x = x + Constants.enemySize
|
|
||||||
|
|
||||||
open GameType
|
open GameType
|
||||||
in
|
in
|
||||||
|
|||||||
Reference in New Issue
Block a user