refactor platform and wall type declarations out into platform.sml and wall.sml
This commit is contained in:
@@ -15,6 +15,18 @@ struct
|
||||
|
||||
structure EnemyMap = MakeGapMap(EnemyPair)
|
||||
|
||||
(* - Updating state of enemies per-frame - *)
|
||||
(*
|
||||
structure UpdateEnemies = MakeGapMapMapper (struct
|
||||
structure Pair = EnemyPair
|
||||
|
||||
type env = {walls: wall vector, wallTree: QuadTree.t, platforms: platform
|
||||
vector, platformTree: QuadTree.t}
|
||||
|
||||
(enemy, walls, wallTree, platforms, platformTree, player, graph) =
|
||||
end)
|
||||
*)
|
||||
|
||||
(* - Generating enemy tree - *)
|
||||
structure EnemyTree =
|
||||
MakeGapMapFolder
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
signature GAME_TYPE =
|
||||
sig
|
||||
type wall = {id: int, x: int, y: int, width: int, height: int}
|
||||
|
||||
type platform = {id: int, x: int, y: int, width: int}
|
||||
|
||||
datatype player_recoil = NO_RECOIL | RECOIL_LEFT of int | RECOIL_RIGHT of int
|
||||
|
||||
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
||||
@@ -37,9 +33,9 @@ sig
|
||||
|
||||
type game_type =
|
||||
{ player: player
|
||||
, walls: wall vector
|
||||
, walls: Wall.t vector
|
||||
, wallTree: QuadTree.t
|
||||
, platforms: platform vector
|
||||
, platforms: Platform.t vector
|
||||
, platformTree: QuadTree.t
|
||||
, enemies: EnemyMap.t
|
||||
, graph: PlatSet.elem vector vector
|
||||
@@ -51,11 +47,6 @@ end
|
||||
|
||||
structure GameType :> GAME_TYPE =
|
||||
struct
|
||||
type wall = {id: int, x: int, y: int, width: int, height: int}
|
||||
|
||||
(* all platforms have a fixed visual height and a fixed collision height *)
|
||||
type platform = {id: int, x: int, y: int, width: int}
|
||||
|
||||
datatype player_recoil = NO_RECOIL | RECOIL_LEFT of int | RECOIL_RIGHT of int
|
||||
|
||||
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
||||
@@ -89,9 +80,9 @@ struct
|
||||
|
||||
type game_type =
|
||||
{ player: player
|
||||
, walls: wall vector
|
||||
, walls: Wall.t vector
|
||||
, wallTree: QuadTree.t
|
||||
, platforms: platform vector
|
||||
, platforms: Platform.t vector
|
||||
, platformTree: QuadTree.t
|
||||
, enemies: EnemyMap.t
|
||||
, graph: PlatSet.elem vector vector
|
||||
|
||||
@@ -158,7 +158,7 @@ struct
|
||||
end
|
||||
|
||||
fun getEnvironmentPatches
|
||||
(input, walls: wall vector, wallTree, platforms, platformTree) =
|
||||
(input, walls: Wall.t vector, wallTree, platforms, platformTree) =
|
||||
let
|
||||
(* react to platform and wall collisions *)
|
||||
val x = Fn.getX input
|
||||
@@ -185,7 +185,7 @@ struct
|
||||
let
|
||||
(* default case:
|
||||
* player will land on platform and stay on the ground there. *)
|
||||
val {y = platY, ...}: GameType.platform =
|
||||
val {y = platY, ...}: Platform.t =
|
||||
Vector.sub (platforms, standPlatID - 1)
|
||||
|
||||
val newY = platY - Fn.entitySize
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
structure Platform =
|
||||
struct
|
||||
type t = {id: int, x: int, y: int, width: int}
|
||||
(* collision height of a platform.
|
||||
* Visual height may (and probably will) be different. *)
|
||||
val platHeight = 5
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
structure Wall =
|
||||
struct
|
||||
type t = {id: int, x: int, y: int, width: int, height: int}
|
||||
|
||||
fun helpGenerateTree (pos, wallVec, acc) =
|
||||
if pos = Vector.length wallVec then
|
||||
acc
|
||||
|
||||
Reference in New Issue
Block a user