done refactoring player-specific logic, and also enemy-specific logic, from player-enemy.sml (which now just calls different functions from the player.sml and enemy.sml modules, to help player-enemy.sml maintain a high level overview)
This commit is contained in:
@@ -12,17 +12,9 @@ struct
|
|||||||
case mainAttack of
|
case mainAttack of
|
||||||
MAIN_ATTACKING =>
|
MAIN_ATTACKING =>
|
||||||
let
|
let
|
||||||
(* when attacking, player collision should be larger than player themselves *)
|
|
||||||
val x = x - Constants.halfPlayerSize
|
|
||||||
val y = y - Constants.halfPlayerSize
|
|
||||||
val size = size * 2
|
|
||||||
|
|
||||||
(* get list of enemies player has collided with *)
|
|
||||||
val enemyCollisions = QuadTree.getCollisions
|
|
||||||
(x, y, size, size, 0, 0, 1920, 1080, 0, enemyTree)
|
|
||||||
|
|
||||||
(* filter enemies based on collisions *)
|
(* filter enemies based on collisions *)
|
||||||
val enemyCollisions = Vector.fromList enemyCollisions
|
val enemyCollisions =
|
||||||
|
Player.getEnemyCollisionsWhenAttacking (x, y, enemyTree)
|
||||||
val enemies = Enemy.filterWhenAttacked
|
val enemies = Enemy.filterWhenAttacked
|
||||||
( Vector.length enemies - 1
|
( Vector.length enemies - 1
|
||||||
, enemyCollisions
|
, enemyCollisions
|
||||||
|
|||||||
@@ -511,8 +511,8 @@ struct
|
|||||||
|
|
||||||
val ww = Constants.worldWidth
|
val ww = Constants.worldWidth
|
||||||
val wh = Constants.worldHeight
|
val wh = Constants.worldHeight
|
||||||
val enemyCollisions = QuadTree.getCollisions
|
val enemyCollisions = QuadTree.getCollisions
|
||||||
(x, y, size, size, 0, 0, ww, wh, 0, enemyTree)
|
(x, y, size, size, 0, 0, ww, wh, 0, enemyTree)
|
||||||
in
|
in
|
||||||
Vector.fromList enemyCollisions
|
Vector.fromList enemyCollisions
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user