tentatively refactor quad tree to make it more succinct + eliminate a class of potential bugs (passing wrong quad values through recursion)

This commit is contained in:
2025-01-27 23:27:52 +00:00
parent 42b42220d0
commit 6369be21fa
14 changed files with 393 additions and 1051 deletions

View File

@@ -34,11 +34,9 @@ struct
val {x, y, health, ...} = enemy
val size = Constants.enemySize
val ww = Constants.worldWidth
val wh = Constants.worldHeight
val hasCollision = QuadTree.hasCollisionAt
(x, y, size, size, 0, 0, ww, wh, ~1, projectileTree)
val hasCollision = QuadHelp.hasCollisionAt
(x, y, size, size, projectileTree)
in
if hasCollision then
if health = 1 then
@@ -182,10 +180,8 @@ struct
val {id, x, y, ...} = Vector.sub (enemyVec, pos)
val size = Constants.enemySize
val ww = Constants.worldWidth
val wh = Constants.worldHeight
val acc = QuadTree.insert (x, y, size, size, 0, 0, ww, wh, id, acc)
val acc = QuadHelp.insert (x, y, size, size, id, acc)
in
helpGenerateTree (pos + 1, enemyVec, acc)
end