-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebug.lua
More file actions
40 lines (34 loc) · 1.15 KB
/
Copy pathDebug.lua
File metadata and controls
40 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
local Signal = require("src.Signal")
local Input = require("src.singleton.Input")
local Window = require("src.singleton.Window")
---Debug-focused manager. By checking `Debug.is_enabled` and adding funcs to the
---`updated` and `drawn` Signals, you can add debug utilities that are easily
---enabled or disabled.
local Debug = {
project_name = "go.love",
-- Semver of this project
version = "1.3.0",
version_name = "Camera & Shaders",
is_enabled = true,
is_hitbox_drawing_enabled = true,
are_debug_keys_enabled = true,
updated = Signal(),
drawn = Signal(),
}
function Debug:update(dt)
if not self.is_enabled then return end
self.updated:emit(dt)
if self.are_debug_keys_enabled then
if Input:pressed("debug_quit") then love.event.quit() end
if Input:pressed("debug_restart") then love.event.quit("restart") end
if Input:pressed("debug_increase_window_size") then Window:resize(Window.scale + 1) end
if Input:pressed("debug_decrease_window_size") then Window:resize(Window.scale - 1) end
if Input:pressed("debug_enable_debug_mode") then debug.debug() end
end
end
function Debug:draw()
if self.is_enabled then
self.drawn:emit()
end
end
return Debug