add xAxis and yAxis fields to enemy type
This commit is contained in:
@@ -4,7 +4,7 @@ struct
|
||||
* to adjust enemy data on collision with projectile *)
|
||||
fun onCollisionWithProjectile (enemy, projectileTree, acc) =
|
||||
let
|
||||
val {x, y, health, id} = enemy
|
||||
val {x, y, health, id, xAxis, yAxis} = enemy
|
||||
|
||||
val size = Constants.enemySize
|
||||
val ww = Constants.worldWidth
|
||||
@@ -18,7 +18,13 @@ struct
|
||||
(* filter out if decrementing health by one = 0 *)
|
||||
acc
|
||||
else
|
||||
{health = health - 1, x = x, y = y, id = id} :: acc
|
||||
{ health = health - 1
|
||||
, x = x
|
||||
, y = y
|
||||
, id = id
|
||||
, xAxis = xAxis
|
||||
, yAxis = yAxis
|
||||
} :: acc
|
||||
else
|
||||
enemy :: acc
|
||||
end
|
||||
@@ -28,7 +34,8 @@ struct
|
||||
acc
|
||||
else
|
||||
let
|
||||
val {id, x, y, health = _} = Vector.sub (enemyVec, pos)
|
||||
val {id, x, y, health = _, xAxis = _, yAxis = _} =
|
||||
Vector.sub (enemyVec, pos)
|
||||
|
||||
val size = Constants.enemySize
|
||||
val ww = Constants.worldWidth
|
||||
@@ -46,7 +53,7 @@ struct
|
||||
let
|
||||
val mid = low + ((high - low) div 2)
|
||||
val enemy = Vector.sub (vec, mid)
|
||||
val {id = curNum, x = _, y = _, health = _} = enemy
|
||||
val {id = curNum, x = _, y = _, health = _, xAxis = _, yAxis = _} = enemy
|
||||
in
|
||||
if curNum = findNum then enemy
|
||||
else if curNum < findNum then helpFind (findNum, vec, mid + 1, high)
|
||||
@@ -56,8 +63,9 @@ struct
|
||||
fun find (findNum, vec) =
|
||||
helpFind (findNum, vec, 0, Vector.length vec - 1)
|
||||
|
||||
fun helpGetDrawVec ({x, y, id = _, health = _}, width, height) =
|
||||
fun helpGetDrawVec (enemy, width, height) =
|
||||
let
|
||||
val {x, y, id = _, health = _, xAxis = _, yAxis = _} = enemy
|
||||
val wratio = width / Constants.worldWidthReal
|
||||
val hratio = height / Constants.worldHeightReal
|
||||
in
|
||||
|
||||
@@ -61,7 +61,8 @@ sig
|
||||
| W_CHARGE of int
|
||||
| W_PROJECTILES of player_projectile vector
|
||||
|
||||
type enemy = {id: int, health: int, x: int, y: int}
|
||||
type enemy =
|
||||
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
||||
|
||||
type game_type =
|
||||
{ player: player
|
||||
@@ -139,7 +140,8 @@ struct
|
||||
| W_CHARGE of int
|
||||
| W_PROJECTILES of player_projectile vector
|
||||
|
||||
type enemy = {id: int, health: int, x: int, y: int}
|
||||
type enemy =
|
||||
{id: int, health: int, x: int, y: int, xAxis: x_axis, yAxis: y_axis}
|
||||
|
||||
type game_type =
|
||||
{ player: player
|
||||
@@ -179,9 +181,30 @@ struct
|
||||
val platforms = Vector.fromList [plat1]
|
||||
val platformTree = Platform.generateTree platforms
|
||||
|
||||
val enemy1 = {id = 1, x = 300, y = 945, health = 5}
|
||||
val enemy2 = {id = 2, x = 555, y = 945, health = 5}
|
||||
val enemy3 = {id = 3, x = 979, y = 945, health = 5}
|
||||
val enemy1 =
|
||||
{ id = 1
|
||||
, x = 300
|
||||
, y = 945
|
||||
, health = 5
|
||||
, xAxis = STAY_STILL
|
||||
, yAxis = ON_GROUND
|
||||
}
|
||||
val enemy2 =
|
||||
{ id = 2
|
||||
, x = 555
|
||||
, y = 945
|
||||
, health = 5
|
||||
, xAxis = STAY_STILL
|
||||
, yAxis = ON_GROUND
|
||||
}
|
||||
val enemy3 =
|
||||
{ id = 3
|
||||
, x = 979
|
||||
, y = 945
|
||||
, health = 5
|
||||
, xAxis = STAY_STILL
|
||||
, yAxis = ON_GROUND
|
||||
}
|
||||
val enemies = Vector.fromList [enemy1, enemy2, enemy3]
|
||||
in
|
||||
{ player = player
|
||||
|
||||
Reference in New Issue
Block a user