-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.lua
More file actions
67 lines (53 loc) · 1.51 KB
/
game.lua
File metadata and controls
67 lines (53 loc) · 1.51 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
game = {}
_DEBUG = false
function game:init()
Concord = require("libs.concord")
_components = Concord.components
_systems = Concord.systems
_worlds = Concord.worlds
_assemblages = Concord.assemblages
Concord.loadComponents("src/components")
Concord.loadSystems("src/systems")
Concord.loadWorlds("src/worlds")
Concord.loadAssemblages("src/assemblages")
end
function game:enter()
_worlds.game:emit("reset")
love.audio.play(_audio["MUSIC"])
_worlds.game:emit("next_room", _constants.PLAYER_STARTING_HEALTH, 1)
end
function game:update(dt)
_worlds.game:emit("update", dt)
end
function game:draw()
_worlds.game:emit("draw")
_worlds.game:emit("draw_ui")
if _DEBUG then
love.graphics.setColor(1, 1, 0)
_worlds.game:emit("draw_debug")
_util.l.render_stats(0, love.graphics.getHeight() * 2 / 3)
-- marker for screen centre
love.graphics.circle("fill", love.graphics.getWidth() / 2, love.graphics.getHeight() / 2, 2)
_util.l.reset_colour()
end
end
function game:keypressed(key, _, _)
if key == "r" then
-- love.event.quit("restart")
elseif key == "f1" then
-- _DEBUG = not _DEBUG
end
_worlds.game:emit("keypressed", key)
end
function game:keyreleased(key)
_worlds.game:emit("keyreleased", key)
end
function game:mousepressed(x, y, button, _, _)
_worlds.game:emit("mousepressed", x, y, button)
end
function game:mousereleased(x, y, button, _, _)
_worlds.game:emit("mousereleased", x, y, button)
end
function game:resize(w, h)
_worlds.game:emit("resize", w, h)
end