forked from Arkendorf/Flioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.lua
98 lines (88 loc) · 1.97 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
graphics = require "graphics"
map = require "map"
game = require "game"
reward = require "reward"
mainmenu = require "mainmenu"
pause = require "pause"
over = require "over"
local window = require "window"
function love.load()
graphics.load()
window.load()
map.load()
game.load()
reward.load()
mainmenu.load()
pause.load()
over.load()
state = "main"
oldstate = "main"
freeze = false
palette = {red = {204, 40, 40}, navy = {64, 51, 102}, blue = {0, 132, 204}, green = {122, 204, 40}, colorbase = {190, 183, 204}}
end
function love.update(dt)
if state == "map" then
map.update(dt)
elseif state == "game" then
game.update(dt)
elseif state == "reward" then
reward.update(dt)
elseif state == "main" then
mainmenu.update(dt)
elseif state == "pause" then
pause.update(dt)
elseif state == "over" then
over.update(dt)
end
window.update(dt)
end
function love.draw()
if freeze == true then
draw(oldstate)
end
draw(state)
window.draw()
love.graphics.setCanvas(canvas.game, canvas.menu)
love.graphics.clear()
love.graphics.setCanvas()
end
function draw(state)
if state == "map" then
map.draw()
elseif state == "game" then
game.draw()
elseif state == "reward" then
reward.draw()
elseif state == "main" then
mainmenu.draw()
elseif state == "pause" then
pause.draw()
elseif state == "over" then
over.draw()
end
end
function love.keypressed(key)
if state == "map" then
map.keypressed(key)
elseif state == "reward" then
reward.keypressed(key)
elseif state == "main" then
mainmenu.keypressed(key)
elseif state == "pause" then
pause.keypressed(key)
elseif state == "over" then
over.keypressed(key)
end
if key == "escape" and state ~= "pause" and state ~= "main" and state ~= "over" then
oldstate = state
state = "pause"
pause.start()
end
end
function love.quit()
mainmenu.save_game()
mainmenu.score()
if char.hp <= 0 then
mainmenu.game_over()
end
end