Mercurial > touhou
comparison 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 |
comparison
equal
deleted
inserted
replaced
329:1bb78c469f64 | 330:16ed1ab1e14b |
---|---|
41 | 41 |
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 | |
47 self.load_game(game, background, replay) | |
48 | |
49 self.clock = pyglet.clock.get_default() | |
50 | |
51 | |
52 def load_game(self, game=None, background=None, replay=None): | |
53 GameRenderer.load_game(self, game, background) | |
46 self.replay_level = None | 54 self.replay_level = None |
47 if not replay or not replay.levels[game.stage-1]: | 55 if not replay or not replay.levels[game.stage-1]: |
48 self.keys = pyglet.window.key.KeyStateHandler() | 56 self.keys = pyglet.window.key.KeyStateHandler() |
49 self.push_handlers(self.keys) | 57 self.push_handlers(self.keys) |
50 else: | 58 else: |
52 self.replay_level = replay.levels[game.stage-1] | 60 self.replay_level = replay.levels[game.stage-1] |
53 self.game.players[0].state.lives = self.replay_level.lives | 61 self.game.players[0].state.lives = self.replay_level.lives |
54 self.game.players[0].state.power = self.replay_level.power | 62 self.game.players[0].state.power = self.replay_level.power |
55 self.game.players[0].state.bombs = self.replay_level.bombs | 63 self.game.players[0].state.bombs = self.replay_level.bombs |
56 self.game.difficulty = self.replay_level.difficulty | 64 self.game.difficulty = self.replay_level.difficulty |
57 | |
58 self.clock = pyglet.clock.get_default() | |
59 | 65 |
60 | 66 |
61 def start(self, width=None, height=None): | 67 def start(self, width=None, height=None): |
62 width = width or (self.game.interface.width if self.game else 640) | 68 width = width or (self.game.interface.width if self.game else 640) |
63 height = height or (self.game.interface.height if self.game else 480) | 69 height = height or (self.game.interface.height if self.game else 480) |