additional refactoring, moving player type into its own directory

This commit is contained in:
2025-02-14 10:13:03 +00:00
parent d1e23b5455
commit 46a1836ae2
12 changed files with 88 additions and 114 deletions

View File

@@ -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

View File

@@ -1 +1 @@
structure EnemyMap = Enemy.EnemyMap
structure EnemyMap = MakeGapMap(EnemyPair)

View 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

View File

@@ -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

View File

@@ -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