draw vision debug lines
This commit is contained in:
parent
ddc6c6da5d
commit
33482c6291
3 changed files with 20 additions and 3 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
(local dev (require "src/levels/dev.fnl"))
|
(local dev (require "src/levels/dev.fnl"))
|
||||||
|
|
||||||
(local level dev)
|
(local level dev)
|
||||||
(local debug false)
|
(local debug true)
|
||||||
|
|
||||||
(var pool nil)
|
(var pool nil)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -98,11 +98,28 @@
|
||||||
(. self.quads (angle-to-direction player.rot))
|
(. self.quads (angle-to-direction player.rot))
|
||||||
(- self.x 3) (- self.y 7)))
|
(- self.x 3) (- self.y 7)))
|
||||||
|
|
||||||
|
|
||||||
|
(lambda draw-vision-debug [self]
|
||||||
|
"draw debug lines and points for player vision"
|
||||||
|
(color.set-color :black)
|
||||||
|
(love.graphics.push)
|
||||||
|
(let [ox (+ self.x (/ width 2))
|
||||||
|
oy (+ self.y (/ height 2))
|
||||||
|
steps 20
|
||||||
|
vision-step (/ (/ math.pi 2) steps)] ; 90 deg / 20
|
||||||
|
(love.graphics.translate ox oy)
|
||||||
|
(love.graphics.rotate (- self.rot (/ (* steps vision-step) 2)))
|
||||||
|
(for [i 1 steps]
|
||||||
|
(love.graphics.rotate vision-step)
|
||||||
|
(love.graphics.line 0 0 50 0))
|
||||||
|
(love.graphics.pop)))
|
||||||
|
|
||||||
(fn player.draw-debug [self]
|
(fn player.draw-debug [self]
|
||||||
"draw player hitbox and direction line"
|
"draw player hitbox and direction line"
|
||||||
(color.set-color :black)
|
(color.set-color :black)
|
||||||
|
(draw-vision-debug self)
|
||||||
(love.graphics.rectangle "line" self.x self.y width height)
|
(love.graphics.rectangle "line" self.x self.y width height)
|
||||||
(love.graphics.rectangle "line" self.x self.y 1 1)
|
; (love.graphics.rectangle "line" self.x self.y 1 1)
|
||||||
(love.graphics.push)
|
(love.graphics.push)
|
||||||
(let [ox (+ self.x (/ width 2)) oy (+ self.y (/ height 2))]
|
(let [ox (+ self.x (/ width 2)) oy (+ self.y (/ height 2))]
|
||||||
(love.graphics.translate ox oy)
|
(love.graphics.translate ox oy)
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
(let [ previousCanvas (love.graphics.getCanvas)]
|
(let [ previousCanvas (love.graphics.getCanvas)]
|
||||||
(love.graphics.setCanvas self.canvas)
|
(love.graphics.setCanvas self.canvas)
|
||||||
(color.set-color :dark-purple)
|
(color.set-color :dark-purple)
|
||||||
(love.graphics.rectangle "fill" 0 0 1000 1000)
|
; (love.graphics.rectangle "fill" 0 0 1000 1000)
|
||||||
(love.graphics.setCanvas previousCanvas)
|
(love.graphics.setCanvas previousCanvas)
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue