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)
|
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 - *)
|
(* - Generating enemy tree - *)
|
||||||
structure EnemyTree =
|
structure EnemyTree =
|
||||||
MakeGapMapFolder
|
MakeGapMapFolder
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
signature GAME_TYPE =
|
signature GAME_TYPE =
|
||||||
sig
|
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_recoil = NO_RECOIL | RECOIL_LEFT of int | RECOIL_RIGHT of int
|
||||||
|
|
||||||
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
||||||
@@ -37,9 +33,9 @@ sig
|
|||||||
|
|
||||||
type game_type =
|
type game_type =
|
||||||
{ player: player
|
{ player: player
|
||||||
, walls: wall vector
|
, walls: Wall.t vector
|
||||||
, wallTree: QuadTree.t
|
, wallTree: QuadTree.t
|
||||||
, platforms: platform vector
|
, platforms: Platform.t vector
|
||||||
, platformTree: QuadTree.t
|
, platformTree: QuadTree.t
|
||||||
, enemies: EnemyMap.t
|
, enemies: EnemyMap.t
|
||||||
, graph: PlatSet.elem vector vector
|
, graph: PlatSet.elem vector vector
|
||||||
@@ -51,11 +47,6 @@ end
|
|||||||
|
|
||||||
structure GameType :> GAME_TYPE =
|
structure GameType :> GAME_TYPE =
|
||||||
struct
|
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_recoil = NO_RECOIL | RECOIL_LEFT of int | RECOIL_RIGHT of int
|
||||||
|
|
||||||
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
datatype player_attacked = NOT_ATTACKED | ATTACKED of int
|
||||||
@@ -89,9 +80,9 @@ struct
|
|||||||
|
|
||||||
type game_type =
|
type game_type =
|
||||||
{ player: player
|
{ player: player
|
||||||
, walls: wall vector
|
, walls: Wall.t vector
|
||||||
, wallTree: QuadTree.t
|
, wallTree: QuadTree.t
|
||||||
, platforms: platform vector
|
, platforms: Platform.t vector
|
||||||
, platformTree: QuadTree.t
|
, platformTree: QuadTree.t
|
||||||
, enemies: EnemyMap.t
|
, enemies: EnemyMap.t
|
||||||
, graph: PlatSet.elem vector vector
|
, graph: PlatSet.elem vector vector
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ struct
|
|||||||
end
|
end
|
||||||
|
|
||||||
fun getEnvironmentPatches
|
fun getEnvironmentPatches
|
||||||
(input, walls: wall vector, wallTree, platforms, platformTree) =
|
(input, walls: Wall.t vector, wallTree, platforms, platformTree) =
|
||||||
let
|
let
|
||||||
(* react to platform and wall collisions *)
|
(* react to platform and wall collisions *)
|
||||||
val x = Fn.getX input
|
val x = Fn.getX input
|
||||||
@@ -185,7 +185,7 @@ struct
|
|||||||
let
|
let
|
||||||
(* default case:
|
(* default case:
|
||||||
* player will land on platform and stay on the ground there. *)
|
* 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)
|
Vector.sub (platforms, standPlatID - 1)
|
||||||
|
|
||||||
val newY = platY - Fn.entitySize
|
val newY = platY - Fn.entitySize
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
structure Platform =
|
structure Platform =
|
||||||
struct
|
struct
|
||||||
|
type t = {id: int, x: int, y: int, width: int}
|
||||||
(* collision height of a platform.
|
(* collision height of a platform.
|
||||||
* Visual height may (and probably will) be different. *)
|
* Visual height may (and probably will) be different. *)
|
||||||
val platHeight = 5
|
val platHeight = 5
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
structure Wall =
|
structure Wall =
|
||||||
struct
|
struct
|
||||||
|
type t = {id: int, x: int, y: int, width: int, height: int}
|
||||||
|
|
||||||
fun helpGenerateTree (pos, wallVec, acc) =
|
fun helpGenerateTree (pos, wallVec, acc) =
|
||||||
if pos = Vector.length wallVec then
|
if pos = Vector.length wallVec then
|
||||||
acc
|
acc
|
||||||
|
|||||||
Reference in New Issue
Block a user