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:
@@ -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) =
|
||||
|
||||
@@ -44,6 +44,7 @@ sig
|
||||
, enemies: defeated_enemies vector
|
||||
, charge: int
|
||||
, projectiles: player_projectile vector
|
||||
, platID: int
|
||||
}
|
||||
|
||||
type enemy =
|
||||
@@ -54,6 +55,7 @@ sig
|
||||
, xAxis: x_axis
|
||||
, yAxis: y_axis
|
||||
, variant: EnemyVariants.t
|
||||
, platID: int
|
||||
}
|
||||
|
||||
type game_type =
|
||||
@@ -115,6 +117,7 @@ struct
|
||||
, enemies: defeated_enemies vector
|
||||
, charge: int
|
||||
, projectiles: player_projectile vector
|
||||
, platID: int
|
||||
}
|
||||
|
||||
type enemy =
|
||||
@@ -125,6 +128,7 @@ struct
|
||||
, xAxis: x_axis
|
||||
, yAxis: y_axis
|
||||
, variant: EnemyVariants.t
|
||||
, platID: int
|
||||
}
|
||||
|
||||
type game_type =
|
||||
@@ -153,6 +157,7 @@ struct
|
||||
, enemies = Vector.fromList []
|
||||
, charge = Constants.maxCharge
|
||||
, projectiles = Vector.fromList []
|
||||
, platID = ~1
|
||||
}
|
||||
|
||||
val wall1 = {id = 1, x = 0, y = 0, width = 100, height = 1080}
|
||||
@@ -181,6 +186,7 @@ struct
|
||||
, xAxis = MOVE_LEFT
|
||||
, yAxis = FALLING
|
||||
, variant = EnemyVariants.FOLLOW_SLIME
|
||||
, platID = ~1
|
||||
}
|
||||
val enemy2 =
|
||||
{ id = 2
|
||||
@@ -190,6 +196,7 @@ struct
|
||||
, xAxis = MOVE_LEFT
|
||||
, yAxis = FALLING
|
||||
, variant = EnemyVariants.PATROL_SLIME
|
||||
, platID = ~1
|
||||
}
|
||||
val enemy3 =
|
||||
{ id = 3
|
||||
@@ -199,6 +206,7 @@ struct
|
||||
, xAxis = MOVE_RIGHT
|
||||
, yAxis = FALLING
|
||||
, variant = EnemyVariants.PATROL_SLIME
|
||||
, platID = ~1
|
||||
}
|
||||
val enemies = Vector.fromList [enemy1]
|
||||
in
|
||||
|
||||
@@ -14,6 +14,7 @@ sig
|
||||
| W_ENEMIES of GameType.defeated_enemies vector
|
||||
| W_CHARGE of int
|
||||
| W_PROJECTILES of GameType.player_projectile vector
|
||||
| W_PLAT_ID of int
|
||||
|
||||
val withPatch: GameType.player * player_patch -> GameType.player
|
||||
val withPatches: GameType.player * player_patch list -> GameType.player
|
||||
@@ -35,6 +36,7 @@ struct
|
||||
| W_ENEMIES of GameType.defeated_enemies vector
|
||||
| W_CHARGE of int
|
||||
| W_PROJECTILES of GameType.player_projectile vector
|
||||
| W_PLAT_ID of int
|
||||
|
||||
fun mkPlayer
|
||||
( health
|
||||
@@ -51,6 +53,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
) =
|
||||
{ yAxis = yAxis
|
||||
, xAxis = xAxis
|
||||
@@ -66,6 +69,7 @@ struct
|
||||
, enemies = enemies
|
||||
, charge = charge
|
||||
, projectiles = projectiles
|
||||
, platID = platID
|
||||
}
|
||||
|
||||
fun withPatch (player, patch) =
|
||||
@@ -85,6 +89,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
} = player
|
||||
in
|
||||
case patch of
|
||||
@@ -104,6 +109,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_Y_AXIS yAxis =>
|
||||
mkPlayer
|
||||
@@ -121,6 +127,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_RECOIL recoil =>
|
||||
mkPlayer
|
||||
@@ -138,6 +145,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_ATTACKED attacked =>
|
||||
mkPlayer
|
||||
@@ -155,6 +163,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_MAIN_ATTACK mainAttack =>
|
||||
mkPlayer
|
||||
@@ -172,6 +181,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_FACING facing =>
|
||||
mkPlayer
|
||||
@@ -189,6 +199,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_HEALTH health =>
|
||||
mkPlayer
|
||||
@@ -206,6 +217,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_X x =>
|
||||
mkPlayer
|
||||
@@ -223,6 +235,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_Y y =>
|
||||
mkPlayer
|
||||
@@ -240,6 +253,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_JUMP_PRESSED jumpPressed =>
|
||||
mkPlayer
|
||||
@@ -257,6 +271,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_ENEMIES enemies =>
|
||||
mkPlayer
|
||||
@@ -274,6 +289,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_CHARGE charge =>
|
||||
mkPlayer
|
||||
@@ -291,6 +307,7 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_PROJECTILES projectiles =>
|
||||
mkPlayer
|
||||
@@ -308,6 +325,25 @@ struct
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
| W_PLAT_ID platID =>
|
||||
mkPlayer
|
||||
( health
|
||||
, xAxis
|
||||
, yAxis
|
||||
, x
|
||||
, y
|
||||
, jumpPressed
|
||||
, recoil
|
||||
, attacked
|
||||
, mainAttack
|
||||
, facing
|
||||
, mainAttackPressed
|
||||
, enemies
|
||||
, charge
|
||||
, projectiles
|
||||
, platID
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user