comparison pytouhou/ui/gamerunner.py @ 331:1b4f04b08729

Add the story mode.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 30 Jun 2012 19:37:21 +0200
parents 16ed1ab1e14b
children 4eca6130f118
comparison
equal deleted inserted replaced
330:16ed1ab1e14b 331:1b4f04b08729
42 width, height = (game.interface.width, game.interface.height) if game else (None, None) 42 width, height = (game.interface.width, game.interface.height) if game else (None, None)
43 pyglet.window.Window.__init__(self, width=width, height=height, 43 pyglet.window.Window.__init__(self, width=width, height=height,
44 caption='PyTouhou', resizable=False) 44 caption='PyTouhou', resizable=False)
45 45
46 self.replay_level = None 46 self.replay_level = None
47 self.load_game(game, background, replay) 47
48 if game:
49 self.load_game(game, background, replay)
48 50
49 self.clock = pyglet.clock.get_default() 51 self.clock = pyglet.clock.get_default()
50 52
51 53
52 def load_game(self, game=None, background=None, replay=None): 54 def load_game(self, game=None, background=None, replay=None):
140 keystate |= 64 142 keystate |= 64
141 if self.keys[pyglet.window.key.RIGHT]: 143 if self.keys[pyglet.window.key.RIGHT]:
142 keystate |= 128 144 keystate |= 128
143 if self.keys[pyglet.window.key.LCTRL]: 145 if self.keys[pyglet.window.key.LCTRL]:
144 keystate |= 256 146 keystate |= 256
145 self.game.run_iter(keystate)
146 else: 147 else:
147 keystate = 0 148 keystate = 0
148 for frame, _keystate, unknown in self.replay_level.keys: 149 for frame, _keystate, unknown in self.replay_level.keys:
149 if self.game.frame < frame: 150 if self.game.frame < frame:
150 break 151 break
151 else: 152 else:
152 keystate = _keystate 153 keystate = _keystate
153 154
154 self.game.run_iter(keystate) 155 self.game.run_iter(keystate)
155 156
156 157
157 def render_game(self): 158 def render_game(self):
158 # Switch to game projection 159 # Switch to game projection
159 #TODO: move that to GameRenderer? 160 #TODO: move that to GameRenderer?