additional refactoring, moving player type into its own directory
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
structure EnemyBehaviour =
|
||||
struct
|
||||
open GameType
|
||||
open EnemyType
|
||||
open EntityType
|
||||
|
||||
(* if player is attacking, does enemy collide with attack? *)
|
||||
fun isCollidingWithPlayerAttack (player: player, enemy: enemy) =
|
||||
fun isCollidingWithPlayerAttack (player: PlayerType.player, enemy: enemy) =
|
||||
let
|
||||
val {x = px, y = py, facing, mainAttack, ...} = player
|
||||
val pSize = Constants.playerSize
|
||||
@@ -14,7 +13,7 @@ struct
|
||||
val eSize = Constants.enemySize
|
||||
in
|
||||
case mainAttack of
|
||||
MAIN_ATTACKING {length, ...} =>
|
||||
PlayerType.MAIN_ATTACKING {length, ...} =>
|
||||
(case facing of
|
||||
FACING_RIGHT =>
|
||||
let
|
||||
@@ -359,7 +358,14 @@ struct
|
||||
end
|
||||
|
||||
fun getFollowPatches
|
||||
(player: player, enemy, wallTree, platformTree, platforms, graph, acc) =
|
||||
( player: PlayerType.player
|
||||
, enemy
|
||||
, wallTree
|
||||
, platformTree
|
||||
, platforms
|
||||
, graph
|
||||
, acc
|
||||
) =
|
||||
let
|
||||
val pID = #platID player
|
||||
val eID = #platID enemy
|
||||
|
||||
@@ -1 +1 @@
|
||||
structure EnemyMap = Enemy.EnemyMap
|
||||
structure EnemyMap = MakeGapMap(EnemyPair)
|
||||
|
||||
11
fcore/enemy/enemy-pair.sml
Normal file
11
fcore/enemy/enemy-pair.sml
Normal file
@@ -0,0 +1,11 @@
|
||||
structure EnemyPair =
|
||||
struct
|
||||
type key = int
|
||||
type value = EnemyType.enemy
|
||||
|
||||
fun l (a: int, b: int) = a < b
|
||||
fun eq (a: int, b: int) = a = b
|
||||
fun g (a: int, b: int) = a > b
|
||||
|
||||
val maxNodeSize = 8
|
||||
end
|
||||
@@ -1,21 +1,6 @@
|
||||
structure Enemy =
|
||||
struct
|
||||
|
||||
structure EnemyPair =
|
||||
struct
|
||||
type key = int
|
||||
type value = EnemyType.enemy
|
||||
|
||||
fun l (a: int, b: int) = a < b
|
||||
fun eq (a: int, b: int) = a = b
|
||||
fun g (a: int, b: int) = a > b
|
||||
|
||||
val maxNodeSize = 8
|
||||
end
|
||||
|
||||
structure EnemyMap = MakeGapMap(EnemyPair)
|
||||
|
||||
(* - Updating state of enemies per-frame - *)
|
||||
(* - Updating state of enemies per loop - *)
|
||||
(*
|
||||
structure UpdateEnemies = MakeGapMapMapper (struct
|
||||
structure Pair = EnemyPair
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
structure FallingEnemies =
|
||||
struct
|
||||
open EnemyType
|
||||
open GameType
|
||||
open EntityType
|
||||
|
||||
fun helpGenerateTree (pos, fallingVec: falling_enemy vector, acc) =
|
||||
@@ -25,12 +24,12 @@ struct
|
||||
, QuadTree.create (Constants.worldWidth, Constants.worldHeight)
|
||||
)
|
||||
|
||||
fun isCollidingWithPlayerAttack (player: GameType.player, fx, fy) =
|
||||
fun isCollidingWithPlayerAttack (player: PlayerType.player, fx, fy) =
|
||||
let
|
||||
val {x = px, y = py, mainAttack, facing, ...} = player
|
||||
in
|
||||
case mainAttack of
|
||||
MAIN_ATTACKING {length, ...} =>
|
||||
PlayerType.MAIN_ATTACKING {length, ...} =>
|
||||
let
|
||||
val px =
|
||||
(case facing of
|
||||
@@ -46,7 +45,7 @@ struct
|
||||
| _ => false
|
||||
end
|
||||
|
||||
fun updateList (pos, vec, player: GameType.player, acc) =
|
||||
fun updateList (pos, vec, player: PlayerType.player, acc) =
|
||||
if pos < 0 then
|
||||
acc
|
||||
else
|
||||
@@ -93,7 +92,7 @@ struct
|
||||
(pos + 1, fallingVec, width, height, ratio, xOffset, yOffset, acc)
|
||||
end
|
||||
|
||||
fun getDrawVec (game: game_type, width, height) =
|
||||
fun getDrawVec (game: GameType.game_type, width, height) =
|
||||
if Vector.length (#fallingEnemies game) = 0 then
|
||||
Vector.fromList []
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user