changeset 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 1bb78c469f64
children 1b4f04b08729
files pytouhou/ui/gamerenderer.pyx pytouhou/ui/gamerunner.py
diffstat 2 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/ui/gamerenderer.pyx
+++ b/pytouhou/ui/gamerenderer.pyx
@@ -29,7 +29,10 @@ cdef class GameRenderer(Renderer):
 
     def __init__(self, resource_loader, game=None, background=None):
         Renderer.__init__(self, resource_loader)
+        self.load_game(game, background)
 
+
+    cpdef load_game(self, game=None, background=None):
         self.game = game
         self.background = background
 
--- 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)