a bit of additional refactoring
This commit is contained in:
@@ -59,10 +59,10 @@ struct
|
|||||||
let
|
let
|
||||||
val enemyCollisions = QuadTree.getCollisions
|
val enemyCollisions = QuadTree.getCollisions
|
||||||
(x, y, size, size, 0, 0, 1920, 1080, 0, enemyTree)
|
(x, y, size, size, 0, 0, 1920, 1080, 0, enemyTree)
|
||||||
val lst = [W_ATTACKED NOT_ATTACKED]
|
|
||||||
val player =
|
val player =
|
||||||
Player.enemyCollisionReaction
|
Player.exitAttackedAndCheckEnemies
|
||||||
(player, enemies, enemyCollisions, lst)
|
(player, enemies, enemyCollisions)
|
||||||
|
|
||||||
val enemies = Enemy.filterProjectileCollisions
|
val enemies = Enemy.filterProjectileCollisions
|
||||||
(Vector.length enemies - 1, enemies, projectileTree, [])
|
(Vector.length enemies - 1, enemies, projectileTree, [])
|
||||||
@@ -74,10 +74,7 @@ struct
|
|||||||
* allowing a brief invincibility period as is common in many games
|
* allowing a brief invincibility period as is common in many games
|
||||||
* *)
|
* *)
|
||||||
let
|
let
|
||||||
val amt = amt + 1
|
val player = Player.incrementAttacked (player, amt)
|
||||||
val attacked = ATTACKED amt
|
|
||||||
val player = Player.withPatch (player, W_ATTACKED attacked)
|
|
||||||
|
|
||||||
val enemies = Enemy.filterProjectileCollisions
|
val enemies = Enemy.filterProjectileCollisions
|
||||||
(Vector.length enemies - 1, enemies, projectileTree, [])
|
(Vector.length enemies - 1, enemies, projectileTree, [])
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -494,6 +494,29 @@ struct
|
|||||||
end
|
end
|
||||||
| [] => PlayerPatch.withPatches (player, acc)
|
| [] => PlayerPatch.withPatches (player, acc)
|
||||||
|
|
||||||
|
fun incrementAttacked (player, amt) =
|
||||||
|
let val patch = ATTACKED (amt + 1)
|
||||||
|
in PlayerPatch.withPatch (player, W_ATTACKED patch)
|
||||||
|
end
|
||||||
|
|
||||||
|
fun exitAttackedAndCheckEnemies (player, enemies, enemyCollisions) =
|
||||||
|
enemyCollisionReaction
|
||||||
|
(player, enemies, enemyCollisions, [W_ATTACKED NOT_ATTACKED])
|
||||||
|
|
||||||
|
fun getEnemyCollisionsWhenAttacking (x, y, enemyTree) =
|
||||||
|
let
|
||||||
|
val x = x - Constants.halfPlayerSize
|
||||||
|
val y = y - Constants.halfPlayerSize
|
||||||
|
val size = Constants.playerSize * 2
|
||||||
|
|
||||||
|
val ww = Constants.worldWidth
|
||||||
|
val wh = Constants.worldHeight
|
||||||
|
val enemyCollisions = QuadTree.getCollisions
|
||||||
|
(x, y, size, size, 0, 0, ww, wh, 0, enemyTree)
|
||||||
|
in
|
||||||
|
Vector.fromList enemyCollisions
|
||||||
|
end
|
||||||
|
|
||||||
(* block is placeholder asset *)
|
(* block is placeholder asset *)
|
||||||
fun helpGetDrawVec (x, y, size, width, height, attacked, mainAttack) =
|
fun helpGetDrawVec (x, y, size, width, height, attacked, mainAttack) =
|
||||||
case mainAttack of
|
case mainAttack of
|
||||||
|
|||||||
Reference in New Issue
Block a user