-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.lua
55 lines (42 loc) · 1.04 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
local LevelScene = require 'level/Scene'
local MenuScene = require 'menu/Scene'
local scene
local key_pressed = {}
local key_held = {}
local controls = {
player1 = { left = 'left', right = 'right', jump = 'up' },
player2 = { left = 'z', right = 'x', jump = 's' }
}
function love.keypressed(k)
key_pressed[k] = true
key_held[k] = true
end
function love.keyreleased(k)
key_held[k] = nil
end
local function reset_keys()
for key in pairs(key_pressed) do
key_pressed[key] = nil
end
end
local load_level_1
local load_level_2
local function load_menu()
scene = MenuScene(key_pressed, load_level_1)
end
function load_level_1()
scene = LevelScene(key_pressed, key_held, controls, 'res/background.png', 'res/level1.tmx', load_menu, load_level_2)
end
function load_level_2()
scene = LevelScene(key_pressed, key_held, controls, 'res/background.png', 'res/level2.tmx', load_menu, load_menu)
end
function love.load()
load_menu()
end
function love.draw()
scene:render()
end
function love.update(dt)
scene:update(dt)
reset_keys()
end