fix compile errors after previous commit (which involved reimplementing the quad tree to eliminate the possibility of a class of bugs I was experiencing; the problem was that the quad bounds were being passed recursively in different functions, but the long argument list in these functions made it difficult to see where the mismatch was)

This commit is contained in:
2025-01-27 23:41:59 +00:00
parent 6369be21fa
commit 9b7d7a1396
12 changed files with 264 additions and 333 deletions

View File

@@ -4,8 +4,7 @@ struct
fun withDefaultYAxis (enemy: enemy) =
case #yAxis enemy of
ON_GROUND =>
EnemyPatch.withPatch (enemy, EnemyPatch.W_Y_AXIS FALLING)
ON_GROUND => EnemyPatch.withPatch (enemy, EnemyPatch.W_Y_AXIS FALLING)
| _ => enemy
fun helpExists (pos, id, collisions) =
@@ -35,8 +34,8 @@ struct
val size = Constants.enemySize
val hasCollision = QuadHelp.hasCollisionAt
(x, y, size, size, projectileTree)
val hasCollision = QuadTree.hasCollisionAt
(x, y, size, size, ~1, projectileTree)
in
if hasCollision then
if health = 1 then
@@ -181,12 +180,17 @@ struct
val size = Constants.enemySize
val acc = QuadHelp.insert (x, y, size, size, id, acc)
val acc = QuadTree.insert (x, y, size, size, id, acc)
in
helpGenerateTree (pos + 1, enemyVec, acc)
end
fun generateTree enemyVec = helpGenerateTree (0, enemyVec, QuadTree.empty)
fun generateTree enemyVec =
helpGenerateTree
( 0
, enemyVec
, QuadTree.create (Constants.worldWidth, Constants.worldHeight)
)
fun helpFind (findNum, vec: enemy vector, low, high) =
(* should only be called when we know enemy already exists in vec *)