extract player patch types and functions to its own module
This commit is contained in:
@@ -46,21 +46,6 @@ sig
|
|||||||
, projectiles: player_projectile vector
|
, projectiles: player_projectile vector
|
||||||
}
|
}
|
||||||
|
|
||||||
datatype player_patch =
|
|
||||||
W_X_AXIS of x_axis
|
|
||||||
| W_Y_AXIS of y_axis
|
|
||||||
| W_RECOIL of player_recoil
|
|
||||||
| W_ATTACKED of player_attacked
|
|
||||||
| W_MAIN_ATTACK of main_attack
|
|
||||||
| W_FACING of facing
|
|
||||||
| W_HEALTH of int
|
|
||||||
| W_X of int
|
|
||||||
| W_Y of int
|
|
||||||
| W_JUMP_PRESSED of bool
|
|
||||||
| W_ENEMIES of defeated_enemies vector
|
|
||||||
| W_CHARGE of int
|
|
||||||
| W_PROJECTILES of player_projectile vector
|
|
||||||
|
|
||||||
type enemy =
|
type enemy =
|
||||||
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
||||||
|
|
||||||
@@ -125,21 +110,6 @@ struct
|
|||||||
, projectiles: player_projectile vector
|
, projectiles: player_projectile vector
|
||||||
}
|
}
|
||||||
|
|
||||||
datatype player_patch =
|
|
||||||
W_X_AXIS of x_axis
|
|
||||||
| W_Y_AXIS of y_axis
|
|
||||||
| W_RECOIL of player_recoil
|
|
||||||
| W_ATTACKED of player_attacked
|
|
||||||
| W_MAIN_ATTACK of main_attack
|
|
||||||
| W_FACING of facing
|
|
||||||
| W_HEALTH of int
|
|
||||||
| W_X of int
|
|
||||||
| W_Y of int
|
|
||||||
| W_JUMP_PRESSED of bool
|
|
||||||
| W_ENEMIES of defeated_enemies vector
|
|
||||||
| W_CHARGE of int
|
|
||||||
| W_PROJECTILES of player_projectile vector
|
|
||||||
|
|
||||||
type enemy =
|
type enemy =
|
||||||
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ structure PlayerPhysics =
|
|||||||
MakePhysics
|
MakePhysics
|
||||||
(struct
|
(struct
|
||||||
type t = GameType.player
|
type t = GameType.player
|
||||||
type patch = GameType.player_patch
|
type patch = PlayerPatch.player_patch
|
||||||
|
|
||||||
(* constants for physics *)
|
(* constants for physics *)
|
||||||
val moveBy = Constants.movePlayerBy
|
val moveBy = Constants.movePlayerBy
|
||||||
@@ -90,7 +90,7 @@ structure PlayerPhysics =
|
|||||||
fun getXAxis ({xAxis, ...}: t) = xAxis
|
fun getXAxis ({xAxis, ...}: t) = xAxis
|
||||||
fun getYAxis ({yAxis, ...}: t) = yAxis
|
fun getYAxis ({yAxis, ...}: t) = yAxis
|
||||||
|
|
||||||
val W_X = GameType.W_X
|
val W_X = PlayerPatch.W_X
|
||||||
val W_Y = GameType.W_Y
|
val W_Y = PlayerPatch.W_Y
|
||||||
val W_Y_AXIS = GameType.W_Y_AXIS
|
val W_Y_AXIS = PlayerPatch.W_Y_AXIS
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
structure PlayerEnemy =
|
structure PlayerEnemy =
|
||||||
struct
|
struct
|
||||||
open GameType
|
open GameType
|
||||||
|
open PlayerPatch
|
||||||
|
|
||||||
fun getEnemyRecoilPatches (player, playerOnRight, acc) =
|
fun getEnemyRecoilPatches (player, playerOnRight, acc) =
|
||||||
if playerOnRight then
|
if playerOnRight then
|
||||||
|
|||||||
320
fcore/player-patch.sml
Normal file
320
fcore/player-patch.sml
Normal file
@@ -0,0 +1,320 @@
|
|||||||
|
signature PLAYER_PATCH =
|
||||||
|
sig
|
||||||
|
datatype player_patch =
|
||||||
|
W_X_AXIS of GameType.x_axis
|
||||||
|
| W_Y_AXIS of GameType.y_axis
|
||||||
|
| W_RECOIL of GameType.player_recoil
|
||||||
|
| W_ATTACKED of GameType.player_attacked
|
||||||
|
| W_MAIN_ATTACK of GameType.main_attack
|
||||||
|
| W_FACING of GameType.facing
|
||||||
|
| W_HEALTH of int
|
||||||
|
| W_X of int
|
||||||
|
| W_Y of int
|
||||||
|
| W_JUMP_PRESSED of bool
|
||||||
|
| W_ENEMIES of GameType.defeated_enemies vector
|
||||||
|
| W_CHARGE of int
|
||||||
|
| W_PROJECTILES of GameType.player_projectile vector
|
||||||
|
|
||||||
|
val withPatches: GameType.player * player_patch list -> GameType.player
|
||||||
|
end
|
||||||
|
|
||||||
|
structure PlayerPatch: PLAYER_PATCH =
|
||||||
|
struct
|
||||||
|
datatype player_patch =
|
||||||
|
W_X_AXIS of GameType.x_axis
|
||||||
|
| W_Y_AXIS of GameType.y_axis
|
||||||
|
| W_RECOIL of GameType.player_recoil
|
||||||
|
| W_ATTACKED of GameType.player_attacked
|
||||||
|
| W_MAIN_ATTACK of GameType.main_attack
|
||||||
|
| W_FACING of GameType.facing
|
||||||
|
| W_HEALTH of int
|
||||||
|
| W_X of int
|
||||||
|
| W_Y of int
|
||||||
|
| W_JUMP_PRESSED of bool
|
||||||
|
| W_ENEMIES of GameType.defeated_enemies vector
|
||||||
|
| W_CHARGE of int
|
||||||
|
| W_PROJECTILES of GameType.player_projectile vector
|
||||||
|
|
||||||
|
fun mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
) =
|
||||||
|
{ yAxis = yAxis
|
||||||
|
, xAxis = xAxis
|
||||||
|
, recoil = recoil
|
||||||
|
, attacked = attacked
|
||||||
|
, mainAttack = mainAttack
|
||||||
|
, mainAttackPressed = mainAttackPressed
|
||||||
|
, facing = facing
|
||||||
|
, health = health
|
||||||
|
, x = x
|
||||||
|
, y = y
|
||||||
|
, jumpPressed = jumpPressed
|
||||||
|
, enemies = enemies
|
||||||
|
, charge = charge
|
||||||
|
, projectiles = projectiles
|
||||||
|
}
|
||||||
|
|
||||||
|
fun withPatch (player, patch) =
|
||||||
|
let
|
||||||
|
val
|
||||||
|
{ yAxis
|
||||||
|
, xAxis
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, mainAttackPressed
|
||||||
|
, facing
|
||||||
|
, health
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
} = player
|
||||||
|
in
|
||||||
|
case patch of
|
||||||
|
W_X_AXIS xAxis =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_Y_AXIS yAxis =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_RECOIL recoil =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_ATTACKED attacked =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_MAIN_ATTACK mainAttack =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_FACING facing =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_HEALTH health =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_X x =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_Y y =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_JUMP_PRESSED jumpPressed =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_ENEMIES enemies =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_CHARGE charge =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
| W_PROJECTILES projectiles =>
|
||||||
|
mkPlayer
|
||||||
|
( health
|
||||||
|
, xAxis
|
||||||
|
, yAxis
|
||||||
|
, x
|
||||||
|
, y
|
||||||
|
, jumpPressed
|
||||||
|
, recoil
|
||||||
|
, attacked
|
||||||
|
, mainAttack
|
||||||
|
, facing
|
||||||
|
, mainAttackPressed
|
||||||
|
, enemies
|
||||||
|
, charge
|
||||||
|
, projectiles
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
fun withPatches (player: GameType.player, lst) =
|
||||||
|
case lst of
|
||||||
|
hd :: tl =>
|
||||||
|
let val player = withPatch (player, hd)
|
||||||
|
in withPatches (player, tl)
|
||||||
|
end
|
||||||
|
| [] => player
|
||||||
|
end
|
||||||
296
fcore/player.sml
296
fcore/player.sml
@@ -1,289 +1,7 @@
|
|||||||
structure Player =
|
structure Player =
|
||||||
struct
|
struct
|
||||||
open GameType
|
open GameType
|
||||||
|
open PlayerPatch
|
||||||
fun mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
) =
|
|
||||||
{ yAxis = yAxis
|
|
||||||
, xAxis = xAxis
|
|
||||||
, recoil = recoil
|
|
||||||
, attacked = attacked
|
|
||||||
, mainAttack = mainAttack
|
|
||||||
, mainAttackPressed = mainAttackPressed
|
|
||||||
, facing = facing
|
|
||||||
, health = health
|
|
||||||
, x = x
|
|
||||||
, y = y
|
|
||||||
, jumpPressed = jumpPressed
|
|
||||||
, enemies = enemies
|
|
||||||
, charge = charge
|
|
||||||
, projectiles = projectiles
|
|
||||||
}
|
|
||||||
|
|
||||||
fun withPatch (player: player, patch) =
|
|
||||||
let
|
|
||||||
val
|
|
||||||
{ yAxis
|
|
||||||
, xAxis
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, mainAttackPressed
|
|
||||||
, facing
|
|
||||||
, health
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
} = player
|
|
||||||
in
|
|
||||||
case patch of
|
|
||||||
W_X_AXIS xAxis =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_Y_AXIS yAxis =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_RECOIL recoil =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_ATTACKED attacked =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_MAIN_ATTACK mainAttack =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_FACING facing =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_HEALTH health =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_X x =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_Y y =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_JUMP_PRESSED jumpPressed =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_ENEMIES enemies =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_CHARGE charge =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
| W_PROJECTILES projectiles =>
|
|
||||||
mkPlayer
|
|
||||||
( health
|
|
||||||
, xAxis
|
|
||||||
, yAxis
|
|
||||||
, x
|
|
||||||
, y
|
|
||||||
, jumpPressed
|
|
||||||
, recoil
|
|
||||||
, attacked
|
|
||||||
, mainAttack
|
|
||||||
, facing
|
|
||||||
, mainAttackPressed
|
|
||||||
, enemies
|
|
||||||
, charge
|
|
||||||
, projectiles
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
fun withPatches (player: player, lst) =
|
|
||||||
case lst of
|
|
||||||
hd :: tl =>
|
|
||||||
let val player = withPatch (player, hd)
|
|
||||||
in withPatches (player, tl)
|
|
||||||
end
|
|
||||||
| [] => player
|
|
||||||
|
|
||||||
(* helper functions checking input *)
|
(* helper functions checking input *)
|
||||||
fun getXAxis (lh, rh) =
|
fun getXAxis (lh, rh) =
|
||||||
@@ -689,17 +407,17 @@ struct
|
|||||||
val player = #player game
|
val player = #player game
|
||||||
|
|
||||||
val patches = getProjectilePatches player
|
val patches = getProjectilePatches player
|
||||||
val player = withPatches (player, patches)
|
val player = PlayerPatch.withPatches (player, patches)
|
||||||
|
|
||||||
val patches = getRecoilPatches player
|
val patches = getRecoilPatches player
|
||||||
val player = withPatches (player, patches)
|
val player = PlayerPatch.withPatches (player, patches)
|
||||||
|
|
||||||
val player =
|
val player =
|
||||||
(* we only accept and handle input if player is not recoiling *)
|
(* we only accept and handle input if player is not recoiling *)
|
||||||
case #recoil player of
|
case #recoil player of
|
||||||
NO_RECOIL =>
|
NO_RECOIL =>
|
||||||
let val patches = getInputPatches (player, input)
|
let val patches = getInputPatches (player, input)
|
||||||
in withPatches (player, patches)
|
in PlayerPatch.withPatches (player, patches)
|
||||||
end
|
end
|
||||||
| _ => player
|
| _ => player
|
||||||
|
|
||||||
@@ -711,15 +429,15 @@ struct
|
|||||||
(fn {angle} => {angle = if angle < 360 then angle + 5 else 0}) e
|
(fn {angle} => {angle = if angle < 360 then angle + 5 else 0}) e
|
||||||
val patches = [W_ENEMIES e]
|
val patches = [W_ENEMIES e]
|
||||||
in
|
in
|
||||||
withPatches (player, patches)
|
PlayerPatch.withPatches (player, patches)
|
||||||
end
|
end
|
||||||
|
|
||||||
val patches = PlayerPhysics.getPatches player
|
val patches = PlayerPhysics.getPatches player
|
||||||
val player = withPatches (player, patches)
|
val player = PlayerPatch.withPatches (player, patches)
|
||||||
|
|
||||||
val patches = getEnvironmentPatches (player, game)
|
val patches = getEnvironmentPatches (player, game)
|
||||||
in
|
in
|
||||||
withPatches (player, patches)
|
PlayerPatch.withPatches (player, patches)
|
||||||
end
|
end
|
||||||
|
|
||||||
(* block is placeholder asset *)
|
(* block is placeholder asset *)
|
||||||
|
|||||||
Reference in New Issue
Block a user