-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
49 lines (41 loc) · 1.16 KB
/
main.lua
File metadata and controls
49 lines (41 loc) · 1.16 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
savegame = require("src/savegame")
game = require('./src/game')
game_over_state = require('./src/game_over_state')
main_menu = require('./src/main_menu')
coins = require('./src/coins')
persisted_state = savegame.load()
current_state = main_menu
local function new_high_score(name, new_score)
savegame.add_score(persisted_state, name, new_score)
savegame.save(persisted_state)
end
function love.load()
love.window.setTitle('Woodman')
love.graphics.setBackgroundColor(255, 255, 255)
normalFont = love.graphics.newFont(12)
semiLargeFont = love.graphics.newFont(22)
largeFont = love.graphics.newFont(40)
love.graphics.setFont(normalFont)
game_over_state.load(new_high_score)
game.load(new_high_score)
coins.load()
main_menu.load()
game.restart()
end
function love.update(delta_time)
if current_state.update then
current_state.update(delta_time)
end
end
function love.draw()
if current_state.draw then
current_state.draw()
end
end
function love.keypressed(key)
if key == "escape" then
os.exit()
elseif current_state.keypressed then
current_state.keypressed(key)
end
end