refactor player and enemy records to have a platID field (representing the last platform that player or enemy stood on), and fix resulting compile errors

This commit is contained in:
2025-01-25 08:41:42 +00:00
parent c8f56f3077
commit c7ed5d3cce
3 changed files with 59 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ sig
| W_Y of int
| W_X_AXIS of GameType.x_axis
| W_Y_AXIS of GameType.y_axis
| W_PLAT_ID of int
val withPatch: GameType.enemy * enemy_patch -> GameType.enemy
@@ -20,8 +21,9 @@ struct
| W_Y of int
| W_X_AXIS of GameType.x_axis
| W_Y_AXIS of GameType.y_axis
| W_PLAT_ID of int
fun mkEnemy (id, health, x, y, xAxis, yAxis, variant) =
fun mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID) =
{ id = id
, health = health
, x = x
@@ -29,18 +31,24 @@ struct
, xAxis = xAxis
, yAxis = yAxis
, variant = variant
, platID = platID
}
fun withPatch (enemy, patch) =
let
val {id, health, x, y, xAxis, yAxis, variant} = enemy
val {id, health, x, y, xAxis, yAxis, variant, platID} = enemy
in
case patch of
W_HEALTH health => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
| W_X x => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
| W_X_AXIS xAxis => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
| W_Y y => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
| W_Y_AXIS yAxis => mkEnemy (id, health, x, y, xAxis, yAxis, variant)
W_HEALTH health =>
mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
| W_X x => mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
| W_X_AXIS xAxis =>
mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
| W_Y y => mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
| W_Y_AXIS yAxis =>
mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
| W_PLAT_ID platID =>
mkEnemy (id, health, x, y, xAxis, yAxis, variant, platID)
end
fun withPatches (enemy, lst) =