refactor file order in preparation for adding GapMap for enemy
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
structure EnemyBehaviour =
|
||||
struct
|
||||
open GameType
|
||||
open EnemyType
|
||||
open EntityType
|
||||
|
||||
(* if player is attacking, does enemy collide with attack? *)
|
||||
fun isCollidingWithPlayerAttack (player: player, enemy: enemy) =
|
||||
let
|
||||
@@ -569,44 +572,40 @@ struct
|
||||
, enemyList
|
||||
, fallingList
|
||||
) =
|
||||
let
|
||||
open EnemyVariants
|
||||
in
|
||||
case #variant enemy of
|
||||
PATROL_SLIME =>
|
||||
updatePatrolState
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, platforms
|
||||
, platformTree
|
||||
, projectileTree
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
| FOLLOW_SLIME =>
|
||||
updateFollowState
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, platforms
|
||||
, platformTree
|
||||
, projectileTree
|
||||
, graph
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
| STRAIGHT_BAT =>
|
||||
updateStraightBat
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, projectileTree
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
end
|
||||
case #variant enemy of
|
||||
PATROL_SLIME =>
|
||||
updatePatrolState
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, platforms
|
||||
, platformTree
|
||||
, projectileTree
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
| FOLLOW_SLIME =>
|
||||
updateFollowState
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, platforms
|
||||
, platformTree
|
||||
, projectileTree
|
||||
, graph
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
| STRAIGHT_BAT =>
|
||||
updateStraightBat
|
||||
( player
|
||||
, enemy
|
||||
, walls
|
||||
, wallTree
|
||||
, projectileTree
|
||||
, enemyList
|
||||
, fallingList
|
||||
)
|
||||
end
|
||||
|
||||
@@ -4,18 +4,18 @@ sig
|
||||
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
|
||||
| W_X_AXIS of EntityType.x_axis
|
||||
| W_Y_AXIS of EntityType.y_axis
|
||||
| W_PLAT_ID of int
|
||||
| W_NEXT_PLAT_ID of int
|
||||
| W_BAT_REST of int
|
||||
| W_BAT_MAX_Y of int
|
||||
| W_BAT_MIN_Y of int
|
||||
| W_BAT_DIR_Y of GameType.bat_dir_y
|
||||
| W_BAT_DIR_Y of EnemyType.bat_dir_y
|
||||
|
||||
val withPatch: GameType.enemy * enemy_patch -> GameType.enemy
|
||||
val withPatch: EnemyType.enemy * enemy_patch -> EnemyType.enemy
|
||||
|
||||
val withPatches: GameType.enemy * enemy_patch list -> GameType.enemy
|
||||
val withPatches: EnemyType.enemy * enemy_patch list -> EnemyType.enemy
|
||||
end
|
||||
|
||||
structure EnemyPatch: ENEMY_PATCH =
|
||||
@@ -24,14 +24,14 @@ struct
|
||||
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
|
||||
| W_X_AXIS of EntityType.x_axis
|
||||
| W_Y_AXIS of EntityType.y_axis
|
||||
| W_PLAT_ID of int
|
||||
| W_NEXT_PLAT_ID of int
|
||||
| W_BAT_REST of int
|
||||
| W_BAT_MAX_Y of int
|
||||
| W_BAT_MIN_Y of int
|
||||
| W_BAT_DIR_Y of GameType.bat_dir_y
|
||||
| W_BAT_DIR_Y of EnemyType.bat_dir_y
|
||||
|
||||
fun mkEnemy
|
||||
( id
|
||||
|
||||
49
fcore/enemy/enemy-type.sml
Normal file
49
fcore/enemy/enemy-type.sml
Normal file
@@ -0,0 +1,49 @@
|
||||
signature ENEMY_TYPE =
|
||||
sig
|
||||
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
|
||||
|
||||
datatype bat_dir_y = UP | DOWN
|
||||
|
||||
type enemy =
|
||||
{ id: int
|
||||
, health: int
|
||||
, x: int
|
||||
, y: int
|
||||
, xAxis: EntityType.x_axis
|
||||
, yAxis: EntityType.y_axis
|
||||
, variant: variant
|
||||
, platID: int
|
||||
, nextPlatID: int
|
||||
, batRest: int
|
||||
, batDirY: bat_dir_y
|
||||
, batMaxY: int
|
||||
, batMinY: int
|
||||
}
|
||||
|
||||
type falling_enemy = {x: int, y: int, variant: variant}
|
||||
end
|
||||
|
||||
structure EnemyType: ENEMY_TYPE =
|
||||
struct
|
||||
datatype variant = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
|
||||
|
||||
datatype bat_dir_y = UP | DOWN
|
||||
|
||||
type enemy =
|
||||
{ id: int
|
||||
, health: int
|
||||
, x: int
|
||||
, y: int
|
||||
, xAxis: EntityType.x_axis
|
||||
, yAxis: EntityType.y_axis
|
||||
, variant: variant
|
||||
, platID: int
|
||||
, nextPlatID: int
|
||||
, batRest: int
|
||||
, batDirY: bat_dir_y
|
||||
, batMaxY: int
|
||||
, batMinY: int
|
||||
}
|
||||
|
||||
type falling_enemy = {x: int, y: int, variant: variant}
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
signature ENEMY_VARIANTS =
|
||||
sig
|
||||
datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT
|
||||
end
|
||||
|
||||
structure EnemyVariants: ENEMY_VARIANTS =
|
||||
struct datatype t = PATROL_SLIME | FOLLOW_SLIME | STRAIGHT_BAT end
|
||||
@@ -1,6 +1,6 @@
|
||||
structure Enemy =
|
||||
struct
|
||||
open GameType
|
||||
open EnemyType
|
||||
|
||||
(* returns a vector of enemies, with new state (like position, etc.).
|
||||
* Also filters any enemies from list if defeated.
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
structure FallingEnemies =
|
||||
struct
|
||||
open EnemyType
|
||||
open GameType
|
||||
open EntityType
|
||||
|
||||
fun helpGenerateTree (pos, fallingVec: falling_enemy vector, acc) =
|
||||
if pos = Vector.length fallingVec then
|
||||
@@ -23,7 +25,7 @@ struct
|
||||
, QuadTree.create (Constants.worldWidth, Constants.worldHeight)
|
||||
)
|
||||
|
||||
fun isCollidingWithPlayerAttack (player: player, fx, fy) =
|
||||
fun isCollidingWithPlayerAttack (player: GameType.player, fx, fy) =
|
||||
let
|
||||
val {x = px, y = py, mainAttack, facing, ...} = player
|
||||
in
|
||||
@@ -44,7 +46,7 @@ struct
|
||||
| _ => false
|
||||
end
|
||||
|
||||
fun updateList (pos, vec, player: player, acc) =
|
||||
fun updateList (pos, vec, player: GameType.player, acc) =
|
||||
if pos < 0 then
|
||||
acc
|
||||
else
|
||||
@@ -55,7 +57,7 @@ struct
|
||||
val ww = Constants.worldWidth
|
||||
val wh = Constants.worldHeight
|
||||
in
|
||||
if isCollidingWithPlayerAttack (player : player, x, y) then
|
||||
if isCollidingWithPlayerAttack (player, x, y) then
|
||||
(* filter out if player is attacking falling enemy *)
|
||||
updateList (pos - 1, vec, player, acc)
|
||||
else if Collision.isCollidingPlus (x, y, size, size, 0, 0, ww, wh) then
|
||||
|
||||
Reference in New Issue
Block a user