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