diff pytouhou/ui/gamerunner.py @ 330:16ed1ab1e14b

Add a GameRunner.load_game method to allow level changes. This will probably get changed later, but this is sufficient to change levels for a story mode or a boss rush mode, for instance. * * * Fix previous patch
author Thibaut Girka <thib@sitedethib.com>
date Sat, 30 Jun 2012 13:02:24 +0200
parents 2fcdb8966957
children 1b4f04b08729
line wrap: on
line diff
--- a/pytouhou/ui/gamerunner.py
+++ b/pytouhou/ui/gamerunner.py
@@ -44,6 +44,14 @@ class GameRunner(pyglet.window.Window, G
                                       caption='PyTouhou', resizable=False)
 
         self.replay_level = None
+        self.load_game(game, background, replay)
+
+        self.clock = pyglet.clock.get_default()
+
+
+    def load_game(self, game=None, background=None, replay=None):
+        GameRenderer.load_game(self, game, background)
+        self.replay_level = None
         if not replay or not replay.levels[game.stage-1]:
             self.keys = pyglet.window.key.KeyStateHandler()
             self.push_handlers(self.keys)
@@ -55,8 +63,6 @@ class GameRunner(pyglet.window.Window, G
             self.game.players[0].state.bombs = self.replay_level.bombs
             self.game.difficulty = self.replay_level.difficulty
 
-        self.clock = pyglet.clock.get_default()
-
 
     def start(self, width=None, height=None):
         width = width or (self.game.interface.width if self.game else 640)