properly implement debug mode

This commit is contained in:
yuki 2025-11-11 20:52:12 -03:00
parent d615bed39a
commit 1c47377dc1
2 changed files with 18 additions and 6 deletions

View file

@ -3,6 +3,7 @@ if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
DEBUG = true
require("lldebugger").start()
else DEBUG = false end
print('debug:', DEBUG)
-- libraries --
---@type Object
@ -70,11 +71,20 @@ function love.update(dt)
if current_room then current_room:update(dt) end
input:update(dt)
if input:pressed('f1') then gotoRoom('CircleRoom') end
if input:pressed('f2') then
-- debug breakpoint
if input:pressed('f2') and DEBUG then
-- global debug breakpoint
print('break')
end
if input:pressed('f3') then camera:shake(4, 60, 1) end
if input:pressed('f10') then
if DEBUG then
print('setting DEBUG to false...')
DEBUG = false
else
print('setting DEBUG to true...')
DEBUG = true
end
end
if input:pressed('f12') then
print("-------------------------------------")
print("Before collection: " .. collectgarbage("count")/1024)

View file

@ -56,10 +56,12 @@ end
function Player:draw()
Player.super.draw(self)
love.graphics.setColor(1, 0.4, 0.4)
self.collider:draw()
love.graphics.setColor(0.4, 1, 0.4)
love.graphics.line(self.x, self.y, self.x + 2*self.w*math.cos(self.r), self.y + 2*self.w*math.sin(self.r))
if DEBUG then
love.graphics.setColor(1, 0.4, 0.4)
self.collider:draw()
love.graphics.setColor(0.4, 1, 0.4)
love.graphics.line(self.x, self.y, self.x + 2*self.w*math.cos(self.r), self.y + 2*self.w*math.sin(self.r))
end
love.graphics.setColor(1, 1, 1)
love.graphics.circle('line', self.x, self.y, self.w)
end