This repository was archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
98 lines (70 loc) · 1.87 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
--[[
TODO:
Level shell
win a level - text syas WIN when you have won
Emitter
Elements can spin in editor
Destroy bug element
Level select screen
make some levels
find some art
incorporate audio
]]--
states = {
startScreen = require "startScreen",
elementEditor =require "elementEditor",
levelList = require "levelSelect",
playLevel =require "playLevel",
boids = require "boids",
}
audio = require "audio"
-- game config
config = {
width = 1600,
height = 900,
showWindowChrome = false,
vortexStrength = 0.05,
repulsorStrength = 0.05
}
--mainState = states.startScreen;
--mainState = states.elementEditor;
mainState = states.levelList;
-- intialization
function love.load()
-- ZeroBrane debugging requirement
if arg[#arg] == "-debug" then require("mobdebug").start() end
-- Set up window
love.window.setMode(config.width, config.height, {centered=true, borderless=not config.showWindowChrome, msaa=8})
-- Really start
if mainState.enter then mainState.enter() end
-- preloads audio assets
audio.load()
sounds.music.level1:play()
end
function love.update(dt)
if mainState.update then mainState.update(dt) end
end
function love.draw()
love.graphics.clear(30,30,30, 255)
mainState.draw()
end
function love.mousereleased(...)
if (mainState.mousereleased) then mainState.mousereleased(...) end
end
function love.mousepressed(...)
if (mainState.mousepressed) then mainState.mousepressed(...) end
end
function love.textinput(text)
if (mainState.textinput) then mainState.textinput(text) end
end
function love.keypressed(...)
if (mainState.keypressed) then mainState.keypressed(...) end
end
function setMainState(state)
if mainState and mainState.exit then mainState.exit() end
mainState = state;
_notifyMainStateEnter();
end
function _notifyMainStateEnter()
if mainState.enter then mainState.enter(config, states) end
end