-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgame.lua
59 lines (52 loc) · 1.63 KB
/
game.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
game = {}
-- states
state = {
-- misc state
idle = {label = 'idle', transition = true},
activated = {label = 'activated', transition = true},
-- anime states
standing = {label = 'standing'},
walking = {label = 'walking'},
jumping = {label = 'jumping'},
suffering = {label = 'suffering'},
attacking = {label = 'attacking'},
dying = {label = 'dying'},
dead = {label = 'dead'},
-- game super states
intro = {label = 'intro'},
tuto = {label = 'tuto'},
ingame = {label = 'ingame'},
success = {label = 'success'},
fail = {label = 'fail'},
cinematic = {label = 'cinematic'},
timeout = {label = 'timeout'},
trophy = {label = 'trophy'},
-- game transitions
beginning = {label = 'beginning', transition = true},
continue = {label = 'continue', transition = true},
retrying = {label = 'retrying', transition = true},
restarting = {label = 'restarting', transition = true},
exiting = {label = 'exiting', transition = true},
reseting = {label = 'reseting', transition = true},
sharing = {label = 'sharing', transition = true},
browsing = {label = 'browsing', transition = true},
}
game.state = state.intro
game.guiState = state.idle
game.pause = false
game.running = true -- switch to false when stopping
game.iLevel = 0
function game:setState(state)
assert(state ~= nil)
self.state = state
-- print("setState", state.label)
waitFor.trigger(waitFor.POKE)
end
function game:waitStateCondition(condition, t)
-- print("wait condition")
while game.running and not condition() do
if waitFor.signal(waitFor.POKE, t) == waitFor.TIMEOUT then
return waitFor.TIMEOUT
end
end
end