derive EnemyPhysics module from functor
This commit is contained in:
@@ -28,4 +28,5 @@ struct
|
|||||||
(* constants for enemy *)
|
(* constants for enemy *)
|
||||||
val enemySize = 35
|
val enemySize = 35
|
||||||
val enemySizeReal: Real32.real = 35.0
|
val enemySizeReal: Real32.real = 35.0
|
||||||
|
val moveEnemyBy = 5
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,18 @@
|
|||||||
structure EnemyPatch =
|
signature ENEMY_PATCH =
|
||||||
|
sig
|
||||||
|
datatype enemy_patch =
|
||||||
|
W_HEALTH of int
|
||||||
|
| W_X of int
|
||||||
|
| W_Y of int
|
||||||
|
| W_X_AXIS of GameType.x_axis
|
||||||
|
| W_Y_AXIS of GameType.y_axis
|
||||||
|
|
||||||
|
val withPatch: GameType.enemy * enemy_patch -> GameType.enemy
|
||||||
|
|
||||||
|
val withPatches: GameType.enemy * enemy_patch list -> GameType.enemy
|
||||||
|
end
|
||||||
|
|
||||||
|
structure EnemyPatch: ENEMY_PATCH =
|
||||||
struct
|
struct
|
||||||
datatype enemy_patch =
|
datatype enemy_patch =
|
||||||
W_HEALTH of int
|
W_HEALTH of int
|
||||||
|
|||||||
@@ -94,3 +94,26 @@ structure PlayerPhysics =
|
|||||||
val W_Y = PlayerPatch.W_Y
|
val W_Y = PlayerPatch.W_Y
|
||||||
val W_Y_AXIS = PlayerPatch.W_Y_AXIS
|
val W_Y_AXIS = PlayerPatch.W_Y_AXIS
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
structure EnemyPhysics =
|
||||||
|
MakePhysics
|
||||||
|
(struct
|
||||||
|
type t = GameType.enemy
|
||||||
|
type patch = EnemyPatch.enemy_patch
|
||||||
|
|
||||||
|
(* constants for physics *)
|
||||||
|
val moveBy = Constants.moveEnemyBy
|
||||||
|
val floatLimit = Constants.floatLimit
|
||||||
|
val jumpLimit = Constants.jumpLimit
|
||||||
|
|
||||||
|
(* destructuring functions *)
|
||||||
|
fun getX ({x, ...}: t) = x
|
||||||
|
fun getY ({y, ...}: t) = y
|
||||||
|
|
||||||
|
fun getXAxis ({xAxis, ...}: t) = xAxis
|
||||||
|
fun getYAxis ({yAxis, ...}: t) = yAxis
|
||||||
|
|
||||||
|
val W_X = EnemyPatch.W_X
|
||||||
|
val W_Y = EnemyPatch.W_Y
|
||||||
|
val W_Y_AXIS = EnemyPatch.W_Y_AXIS
|
||||||
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user