From 1c47377dc17e699f9d479c691e003a4429ea637d Mon Sep 17 00:00:00 2001 From: yuki Date: Tue, 11 Nov 2025 20:52:12 -0300 Subject: [PATCH] properly implement debug mode --- main.lua | 14 ++++++++++++-- obj/game/Player.lua | 10 ++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/main.lua b/main.lua index 718c23f..1097041 100644 --- a/main.lua +++ b/main.lua @@ -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) diff --git a/obj/game/Player.lua b/obj/game/Player.lua index 94ad200..03f72b4 100644 --- a/obj/game/Player.lua +++ b/obj/game/Player.lua @@ -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