Mercurial > touhou
diff pytouhou/games/sample/game.py @ 614:2cf518129725
Delay power assignment to players until the game is started.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 28 Mar 2015 21:02:05 +0100 |
parents | 2a748aa29c3f |
children | d1f0bb0b7a17 |
line wrap: on
line diff
--- a/pytouhou/games/sample/game.py +++ b/pytouhou/games/sample/game.py @@ -27,7 +27,9 @@ from . import enemies, shots class Common(object): - def __init__(self, resource_loader, player_characters, continues, stage, + default_power = [0, 64, 128, 128, 128, 128, 0] + + def __init__(self, resource_loader, player_characters, continues, *, width=384, height=448): self.width, self.height = width, height @@ -76,8 +78,6 @@ class Common(object): ('face09b.anm', 'face10a.anm', 'face10b.anm'), ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] - default_power = [0, 64, 128, 128, 128, 128, 0][stage] - sample_characters = shots.characters self.first_character = player_characters[0] // 2 self.player_anms = {} @@ -93,7 +93,7 @@ class Common(object): self.players[i] = Player(i, self.player_anms[character][0], sample_characters[player_character], - character, default_power, continues) + character, continues) @@ -125,6 +125,8 @@ class Game(GameBase): for player in common.players: player._game = self + if player.power < 0: + player.power = common.default_power[stage - 1] # Load stage data self.std = resource_loader.get_stage('stage%d.std' % stage) @@ -143,11 +145,11 @@ class Game(GameBase): class Player(PlayerBase): - def __init__(self, number, anm, shts, character, power, continues): + def __init__(self, number, anm, shts, character, continues): self.sht = shts[0] self.focused_sht = shts[1] - PlayerBase.__init__(self, number, anm, character, power, continues) + PlayerBase.__init__(self, number, anm, character, continues, power=-1) self.orbs = [Orb(anm, 128, self), Orb(anm, 129, self)]