render radar boxes

This commit is contained in:
Travis Shears 2026-05-09 22:05:38 +02:00
parent bd12a4d504
commit 925d375313
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
4 changed files with 59 additions and 21 deletions

View file

@ -30,6 +30,9 @@
(love.graphics.line x1 y1 x1 (+ y1 1000))
(love.graphics.print (.. (string.format "%d" x1) "," (string.format "%d" y1)) (+ x1 3) (+ y1 3)))))))
; (lambda gen-wall-collider-box [x y width height]
; )
(fn walls.load [self]
(set self.batch (love.graphics.newSpriteBatch assets.walls-sprite 2500))
;; load quads
@ -37,8 +40,8 @@
(for [i 0 19 1]
(table.insert self.quads (love.graphics.newQuad (* i 25) 0 25 25 w h))))
;; fill batch
(each [_ row (pairs (. levels :levels self.pool.data.level-key :tiles))]
(each [_ tile (pairs row)]
(each [row-key row (pairs (. levels :levels self.pool.data.level-key :tiles))]
(each [tile-key tile (pairs row)]
(let [
x tile.x
y tile.y
@ -47,12 +50,12 @@
(if (and (> id 0) (< id 21)) ;; 1-20 are wall tiles
(do
(self.batch:add (. self.quads id) (if tile.h-flip (+ x 25) x) y 0 (if tile.h-flip -1 1) 1)
(each [_ collider (pairs colliders)]
(each [collider-key collider (pairs colliders)]
(let [
mirrored-collider (if tile.h-flip (mirror-collider collider) collider)
collider-x (+ x mirrored-collider.x)
collider-y (+ y mirrored-collider.y)]
(self.pool.data.bump-world:add {: x : y :name :wall :behavior :block} collider-x collider-y mirrored-collider.width mirrored-collider.height)
(self.pool.data.bump-world:add {:id (.. row-key tile-key collider-key) : x : y :name :wall :behavior :block :w mirrored-collider.width :h mirrored-collider.height} collider-x collider-y mirrored-collider.width mirrored-collider.height)
(table.insert
self.collider-debug-boxes
{:x collider-x :y collider-y :width mirrored-collider.width :height mirrored-collider.height}))))))))
@ -65,7 +68,7 @@
)
(fn walls.draw49 [self]
(fn walls.draw40 [self]
(color.reset-color)
(love.graphics.draw self.batch))