-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsceneManager.lua
More file actions
81 lines (71 loc) · 1.74 KB
/
sceneManager.lua
File metadata and controls
81 lines (71 loc) · 1.74 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
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
local sceneManager = {}
local title = require("titleScreen")
local level = require("level")
local gameOver = require("gameOver")
local victory = require("victory")
local ui = require("ui")
sceneManager.sceneCourante = title
sceneManager.index = 1
-----------------------------------
function sceneManager.Update(dt)
if ui.lifeManager.currentLife == 0 then
sceneManager.sceneCourante = gameOver
sceneManager.index = 3
end
if level.wonTheGame == true then
sceneManager.sceneCourante = victory
sceneManager.index = 4
victory.music:play()
love.mouse.setGrabbed(false)
end
sceneManager.sceneCourante.Update(dt)
end
-----------------------------------
function sceneManager.Draw()
sceneManager.sceneCourante.Draw()
end
function sceneManager.Keypressed(key)
-- navigate menus
if key == "y" and
sceneManager.index == 1 then
sceneManager.sceneCourante = level
sceneManager.index = 2
level.Load(1)
elseif key == "y" and
sceneManager.index == 3 then
sceneManager.sceneCourante = level
sceneManager.index = 2
level.Load(level.currentLevel)
elseif key == "y" and
sceneManager.index == 2 and
level.isPaused == true and
ui.pauseMenu == true then
level.isPaused = false
ui.pauseMenu = false
end
-- quit game
if key == "n" and
sceneManager.index == 1 then
love.event.quit()
elseif key == "n" and
sceneManager.index == 3 then
love.event.quit()
elseif key == "n" and
sceneManager.index == 2 and
level.isPaused == true and
ui.pauseMenu == true then
love.event.quit()
end
-- pause
if key == "escape" and
sceneManager.index == 2 then
if level.isPaused == true then
level.isPaused = false
ui.pauseMenu = false
else
level.isPaused = true
ui.pauseMenu = true
end
end
end
return(sceneManager)