comparison pytouhou/games/eosd/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 244c99c568c8
children d1f0bb0b7a17
comparison
equal deleted inserted replaced
613:560b45a7d014 614:2cf518129725
24 24
25 from pytouhou.vm import ECLMainRunner 25 from pytouhou.vm import ECLMainRunner
26 26
27 27
28 class Common(object): 28 class Common(object):
29 def __init__(self, resource_loader, player_characters, continues, stage, 29 default_power = [0, 64, 128, 128, 128, 128, 0]
30
31 def __init__(self, resource_loader, player_characters, continues, *,
30 width=384, height=448): 32 width=384, height=448):
31 self.width, self.height = width, height 33 self.width, self.height = width, height
32 34
33 self.etama = resource_loader.get_multi_anm(('etama3.anm', 'etama4.anm')) 35 self.etama = resource_loader.get_multi_anm(('etama3.anm', 'etama4.anm'))
34 self.bullet_types = [BulletType(self.etama[0], 0, 11, 14, 15, 16, hitbox_size=2, 36 self.bullet_types = [BulletType(self.etama[0], 0, 11, 14, 15, 16, hitbox_size=2,
73 ('face08a.anm', 'face08b.anm'), 75 ('face08a.anm', 'face08b.anm'),
74 ('face09a.anm', 'face09b.anm'), 76 ('face09a.anm', 'face09b.anm'),
75 ('face09b.anm', 'face10a.anm', 'face10b.anm'), 77 ('face09b.anm', 'face10a.anm', 'face10b.anm'),
76 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')] 78 ('face08a.anm', 'face12a.anm', 'face12b.anm', 'face12c.anm')]
77 79
78 default_power = [0, 64, 128, 128, 128, 128, 0][stage]
79
80 eosd_characters = resource_loader.get_eosd_characters() 80 eosd_characters = resource_loader.get_eosd_characters()
81 self.first_character = player_characters[0] // 2 81 self.first_character = player_characters[0] // 2
82 self.player_anms = {} 82 self.player_anms = {}
83 self.players = [None] * len(player_characters) 83 self.players = [None] * len(player_characters)
84 for i, player_character in enumerate(player_characters): 84 for i, player_character in enumerate(player_characters):
90 anm = resource_loader.get_single_anm('player0%d.anm' % character) 90 anm = resource_loader.get_single_anm('player0%d.anm' % character)
91 self.player_anms[character] = (anm, face) 91 self.player_anms[character] = (anm, face)
92 92
93 self.players[i] = Player(i, self.player_anms[character][0], 93 self.players[i] = Player(i, self.player_anms[character][0],
94 eosd_characters[player_character], 94 eosd_characters[player_character],
95 character, default_power, continues) 95 character, continues)
96 96
97 97
98 98
99 class Game(GameBase): 99 class Game(GameBase):
100 def __init__(self, resource_loader, stage, rank, difficulty, 100 def __init__(self, resource_loader, stage, rank, difficulty,
122 for sprite in anm.sprites.values(): 122 for sprite in anm.sprites.values():
123 self.msg_anm[i].append((anm, sprite)) 123 self.msg_anm[i].append((anm, sprite))
124 124
125 for player in common.players: 125 for player in common.players:
126 player._game = self 126 player._game = self
127 if player.power < 0:
128 player.power = common.default_power[stage - 1]
127 129
128 # Load stage data 130 # Load stage data
129 self.std = resource_loader.get_stage('stage%d.std' % stage) 131 self.std = resource_loader.get_stage('stage%d.std' % stage)
130 132
131 background_anm = resource_loader.get_single_anm('stg%dbg.anm' % stage) 133 background_anm = resource_loader.get_single_anm('stg%dbg.anm' % stage)
150 pass 152 pass
151 153
152 154
153 155
154 class Player(PlayerBase): 156 class Player(PlayerBase):
155 def __init__(self, number, anm, shts, character, power, continues): 157 def __init__(self, number, anm, shts, character, continues):
156 self.sht = shts[0] 158 self.sht = shts[0]
157 self.focused_sht = shts[1] 159 self.focused_sht = shts[1]
158 160
159 PlayerBase.__init__(self, number, anm, character, power, continues) 161 PlayerBase.__init__(self, number, anm, character, continues, power=-1)
160 162
161 self.orbs = [Orb(anm, 128, self), 163 self.orbs = [Orb(anm, 128, self),
162 Orb(anm, 129, self)] 164 Orb(anm, 129, self)]
163 165
164 self.orbs[0].offset_x = -24 166 self.orbs[0].offset_x = -24