fix bug in physics.sml where player/enemy would drop below continuously past multiple platforms even if they intended to drop below platforms only once (fixed by setting yAxis to 'FALLING' if there are no collisions at all and player is in DROP_BELOW_PLATFORMS state)

This commit is contained in:
2025-01-18 22:13:16 +00:00
parent 6812f61dcc
commit edf7d4c8dc
2 changed files with 33 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
structure EnemyBehaviour =
1tructure EnemyBehaviour =
struct
open GameType
@@ -143,6 +143,22 @@ struct
fun hasVisted (find, visited) =
helpHasVisited (0, Char.chr find, visited)
fun isBetween (p1, check, p2) = check >= p1 andalso check <= p2
fun isReachableFromBottom (prevPlat: platform, currentPlat: platform) =
let
val {x = prevX, y = prevY, width = prevWidth, ...} = prevPlat
val {x = curX, y = curY, width = curWidth, ...} = currentPlat
val prevFinishX = prevX + prevWidth
val curFinishX = curX + curWidth
in
(isBetween (prevX, curX, prevFinishX)
orelse
isBetween (prevX, curFinishX, prevFinishX)
andalso prevY + Constants.jumpLimit >= curY)
end
fun isReachableFromLeft (prevPlat, currentPlat) =
(* prev = right/from, current = left/to *)
let