-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·93 lines (63 loc) · 1.88 KB
/
main.py
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
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env python
from game import *
from world import *
from utilities.core import *
from utilities.messaging import Forum
class PongLoop(Loop):
# Constructor {{{1
def __init__(self):
self.engine = PregameEngine(self)
# }}}1
class PregameEngine(GameEngine):
# Constructor {{{1
def __init__(self, loop):
Engine.__init__(self, loop)
self.world = World()
self.player = Player(self)
# Game Loop {{{1
def setup(self):
self.player.setup_pregame()
self.countdown = settings.countdown
def update(self, time):
self.player.update_pregame(time)
if self.countdown < 0:
self.exit_engine()
else:
self.countdown -= time
def teardown(self):
self.player.teardown_pregame()
def successor(self):
return PongEngine(self.loop, self.world, self.player)
# }}}1
class PongEngine(GameEngine):
# Constructor {{{1
def __init__(self, loop, world, player):
GameEngine.__init__(self, loop)
self.world = world
self.game = Game(self)
self.tasks = {
"triggers" : Triggers(self),
"player" : player.reset(self),
"opponent" : Opponent(self) }
# Game Loop {{{1
def successor(self):
player = self.tasks["player"]
return PostgameEngine(self.loop, self.world, player)
# }}}1
class PostgameEngine(Engine):
# Constructor {{{1
def __init__(self, loop, world, player):
Engine.__init__(self, loop)
self.world = world
self.player = player
# Game Loop {{{1
def setup(self):
self.player.setup_postgame()
def update(self, time):
self.player.update_postgame(time)
def teardown(self):
self.player.teardown_postgame()
# }}}1
if __name__ == "__main__":
loop = PongLoop()
loop.play()