-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
93 lines (74 loc) · 1.62 KB
/
main.lua
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
require "game"
require "titleScreen"
local Baton = require "vendor.baton.baton"
Audio = require "audio"
local launchType = arg[2]
require "bar"
DEBUG_MODE = false
TEST_MODE = false
RELEASE = false
local debugControls = nil
if launchType == "test" or launchType == "debug" then
require "lldebugger"
DEBUG_MODE = true
if launchType == "debug" then
lldebugger.start()
debugControls = Baton.new
{
controls = {
drawDebug = {'key:f12'},
}
}
else
TEST_MODE = true
end
else
RELEASE = true
end
---@diagnostic disable-next-line: undefined-field
local love_errorhandler = love.errhand
function love.errorhandler(msg)
if lldebugger then
lldebugger.start()
error(msg, 2)
else
return love_errorhandler(msg)
end
end
CurrentWorld = nil
CurrentGame = nil
MainGame = nil
Title = nil
function love.load()
local windowTitle = "Magna Classic"
if TEST_MODE then
windowTitle = windowTitle .. " (Test)"
elseif DEBUG_MODE then
windowTitle = windowTitle .. " (Debug)"
end
love.window.setTitle(windowTitle)
CurrentGame = TitleScreen:new()
Title = CurrentGame
MainGame = Game:new()
CurrentWorld = MainGame.world
local iconData = love.image.newImageData("assets/magna_icon.png")
love.window.setIcon(iconData);
Audio.music:setLooping(true)
love.audio.play(Audio.music)
end
function love.update(dt)
if debugControls then
debugControls:update()
-- Toggles debug drawing
if debugControls:pressed("drawDebug") then
DRAW_DEBUG = not DRAW_DEBUG
end
end
CurrentGame:update(dt)
end
function love.draw()
CurrentGame:draw()
end
function love.keypressed(key, scancode)
if key == "m" then Audio:toggleMute() end
end