-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.lua
77 lines (63 loc) · 1.89 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
return function(world)
local fsm = FSM()
fsm.addState({
name = "start",
init = function ()
world:init()
BasicMovementModule = require("player/movement")
BasicArmorModule = require("player/armor")
BasicXBuster = require("player/x_buster")
AnimationModule = require("player/animation")
players = {
Player(32, 140, "p1", "rock"),
Player(110, 300, "p2", "opera"),
Player(370, 300, "p3", "proto"),
Player(560, 140, "p4", "violet")
}
for _, v in ipairs(players) do
world:register(v)
v.init(BasicMovementModule, BasicArmorModule, BasicXBuster, AnimationModule)
end
hud = HUD.new(unpack(players))
gj = GameJolt("1", nil)
Sound:stop()
Sound:run("mainMusic")
end,
draw = function ()
world:draw()
hud:draw()
end,
update = function (dt)
world:update(dt)
end,
keypressed = function (key)
world:keypressed(key)
end,
keyreleased = function (key)
world:keyreleased(key)
end
})
fsm.addState({
name = "stop",
--init = game.init,
--draw = game.drawfunction,
--update = game.update,
--keypressed = game.keypressed
})
-- start the game when the rock chooses a menu option
fsm.addTransition({
from = "start",
to = "stop",
condition = function ()
return fsm.isSet("reset")
end
})
fsm.addTransition({
from = "stop",
to = "start",
condition = function ()
return true
end
})
return fsm
end