-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
150 lines (132 loc) · 4.32 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
__love = "LÖVE" --because I can't type the O with Umlaut
__debug = (love.system.getOS() == "Android") or true
__filter = "nearest"
__window = 1
__scale = 1
__version = require("modules.semver.semver")(0, 1, 4)
local log = require("modules.log.log")
local lily = require("modules.lily.lily")
local timer = require("modules.hump.timer")
local flux = require("modules.flux.flux")
local inspect = require("modules.inspect.inspect")
local ecs = require("modules.concord.lib").init({ useEvents = false })
local font = love.graphics.newFont(16)
local debugging
log.outfile = "log.log"
log.level = "trace"
log.lovesave = true
if __debug then
require("imgui")
io.stdout:setvbuf("no")
debugging = require("src.debug")
love.audio.setVolume(0)
end
local assets = require("src.assets")
local data = require("src.data")
local time = require("src.time")
local gamestate = require("src.gamestate")
local screen = require("src.screen")
local preload = require("src.preload")
local transition = require("src.transition")
local event = require("src.event")
local touch = require("src.touch")
local soundManager = require("src.sound_manager")
local bgm = require("src.bgm")
__scale = math.min((love.graphics.getWidth()/screen.x), (love.graphics.getHeight()/screen.y))
log.info(("Device: %s x %s"):format(love.graphics.getDimensions()))
log.info(("Game: %s x %s"):format(screen.x, screen.y))
log.info("Scale: " .. __scale)
function love.load(args)
log.trace("Love Load")
log.trace(("Screen Size: %ix%i"):format(screen.x, screen.y))
if __debug then
love.window.setMode(960, love.graphics.getHeight())
love.window.setPosition(1280 - love.graphics.getWidth(), 0)
debugging:init()
end
math.randomseed(os.time())
touch:init()
data:init()
event:init()
transition:init()
preload:init()
gamestate:start( require("states").splash )
-- gamestate:start( require("states").menu )
-- gamestate:start( require("states").intro )
-- gamestate:start( require("states").customization )
-- gamestate:start( require("states").lobby )
-- gamestate:start( require("states").map )
end
function love.update(dt)
if __debug then debugging:update(dt) end
timer.update(dt)
flux.update(dt)
time:update(dt)
touch:update(dt)
preload:update(dt)
bgm:update()
gamestate:update(dt)
end
function love.draw()
love.graphics.push()
love.graphics.scale(__scale, __scale)
preload:draw()
gamestate:draw()
transition:draw()
touch:draw()
if __debug then debugging:draw() end
love.graphics.pop()
end
function love.keypressed(key)
gamestate:keypressed(key)
if __debug and debugging.keypressed then debugging:keypressed(key) end
end
function love.keyreleased(key)
gamestate:keyreleased(key)
if __debug and debugging.keyreleased then debugging:keyreleased(key) end
end
function love.mousepressed(mx, my, mb, istouch, count)
gamestate:mousepressed(mx, my, mb, istouch, count)
touch:simulateTouchPressed(mx, my)
if __debug and debugging.mousepressed then debugging:mousepressed(mx, my, mb, istouch, count) end
end
function love.mousereleased(mx, my, mb, istouch, count)
gamestate:mousereleased(mx, my, mb, istouch, count)
touch:simulateTouchReleased(mx, my)
if __debug and debugging.mousereleased then debugging:mousereleased(mx, my, mb, istouch, count) end
end
function love.wheelmoved(wx, wy)
if __debug and debugging.wheelmoved then debugging:wheelmoved(wx, wy) end
end
function love.mousemoved(mx, my)
if __debug and debugging.mousemoved then debugging:mousemoved(mx, my) end
end
function love.touchpressed(id, tx, ty, dx, dy, pressure)
local tx = tx/__scale
local ty = ty/__scale
touch:touchpressed(id, tx, ty, dx, dy, pressure)
gamestate:touchpressed(id, tx, ty, dx, dy, pressure)
end
function love.touchreleased(id, tx, ty, dx, dy, pressure)
local tx = tx/__scale
local ty = ty/__scale
touch:touchreleased(id, tx, ty, dx, dy, pressure)
gamestate:touchreleased(id, tx, ty, dx, dy, pressure)
end
function love.touchmoved(id, tx, ty, dx, dy, pressure)
local tx = tx/__scale
local ty = ty/__scale
touch:touchmoved(id, tx, ty, dx, dy, pressure)
gamestate:touchmoved(id, tx, ty, dx, dy, pressure)
end
function love.textinput(t)
gamestate:textinput(t)
if __debug and debugging.textinput then debugging:textinput(t) end
end
love.errhand = require("src.errorhandler").errhand
function love.quit()
log.trace("Love Quit")
data:save()
lily.quit()
if __debug and debugging.quit then debugging:quit() end
end