add debug grid
This commit is contained in:
parent
7432203d7b
commit
cffdeda2e9
5 changed files with 64 additions and 55 deletions
|
|
@ -6,6 +6,7 @@
|
|||
:quads []
|
||||
:batch nil
|
||||
:collider-debug-boxes []
|
||||
:debug-grid-canvas nil
|
||||
})
|
||||
|
||||
(lambda mirror-collider [collider]
|
||||
|
|
@ -18,6 +19,17 @@
|
|||
:height collider.height
|
||||
})
|
||||
|
||||
(fn draw-debug-grid []
|
||||
(let [f (love.graphics.newFont 6)]
|
||||
(love.graphics.setFont f)
|
||||
(for [x 0 100 1]
|
||||
(for [y 0 100 1]
|
||||
(let [x1 (* x 100)
|
||||
y1 (* y 100)]
|
||||
(love.graphics.line x1 y1 (+ x1 1000) y1)
|
||||
(love.graphics.line x1 y1 x1 (+ y1 1000))
|
||||
(love.graphics.print (.. (string.format "%d" x1) "," (string.format "%d" y1)) (+ x1 3) (+ y1 3)))))))
|
||||
|
||||
(fn walls.load [self]
|
||||
(set self.batch (love.graphics.newSpriteBatch assets.walls-sprite 2500))
|
||||
;; load quads
|
||||
|
|
@ -43,15 +55,26 @@
|
|||
(self.pool.data.bump-world:add {: x : y :name :wall :behavior :block} 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})))))))))
|
||||
{:x collider-x :y collider-y :width mirrored-collider.width :height mirrored-collider.height}))))))))
|
||||
|
||||
|
||||
(set self.debug-grid-canvas (love.graphics.newCanvas 1000 1000))
|
||||
(love.graphics.setCanvas self.debug-grid-canvas)
|
||||
(draw-debug-grid)
|
||||
(love.graphics.setCanvas)
|
||||
|
||||
)
|
||||
|
||||
(fn walls.draw49 [self]
|
||||
(color.reset-color)
|
||||
(love.graphics.draw self.batch))
|
||||
|
||||
|
||||
(fn walls.draw-debug [self]
|
||||
"draw collider debug boxes"
|
||||
(color.set-color :black)
|
||||
; (draw-debug-grid)
|
||||
(love.graphics.draw self.debug-grid-canvas 0 0)
|
||||
(each [_ collider (pairs self.collider-debug-boxes)]
|
||||
(love.graphics.rectangle "line" collider.x collider.y collider.width collider.height)))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue