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