Mercurial > touhou
comparison eosd @ 465:5f5955635d2c
Move continues to PlayerState, and make sure they aren’t reinitialized before each stage.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 11 Sep 2013 16:03:55 +0200 |
parents | ec327e58b477 |
children | 58b47e788c59 |
comparison
equal
deleted
inserted
replaced
464:36bc577b2392 | 465:5f5955635d2c |
---|---|
121 continues = 0 | 121 continues = 0 |
122 | 122 |
123 if debug: | 123 if debug: |
124 if not verbosity: | 124 if not verbosity: |
125 verbosity = 'DEBUG' | 125 verbosity = 'DEBUG' |
126 continues = float('inf') | 126 continues = -1 # Infinite lives |
127 | 127 |
128 if verbosity: | 128 if verbosity: |
129 logging.basicConfig(level=logging.__getattribute__(verbosity)) | 129 logging.basicConfig(level=logging.__getattribute__(verbosity)) |
130 | 130 |
131 if replay: | 131 if replay: |
144 with open(hints, 'rb') as file: | 144 with open(hints, 'rb') as file: |
145 hints = Hint.read(file) | 145 hints = Hint.read(file) |
146 | 146 |
147 difficulty = 16 | 147 difficulty = 16 |
148 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] | 148 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] |
149 states = [PlayerState(character=character, power=default_power)] | 149 states = [PlayerState(character=character, power=default_power, continues=continues)] |
150 | 150 |
151 game_class = GameBossRush if boss_rush else Game | 151 game_class = GameBossRush if boss_rush else Game |
152 | 152 |
153 common = Common(resource_loader) | 153 common = Common(resource_loader) |
154 runner = GameRunner(window, resource_loader, skip=skip_replay) | 154 runner = GameRunner(window, resource_loader, skip=skip_replay) |
186 level.difficulty = difficulty | 186 level.difficulty = difficulty |
187 save_keystates = [] | 187 save_keystates = [] |
188 | 188 |
189 hints_stage = hints.stages[stage_num - 1] if hints else None | 189 hints_stage = hints.stages[stage_num - 1] if hints else None |
190 | 190 |
191 game = game_class(resource_loader, states, stage_num, rank, difficulty, common, prng=prng, continues=continues, hints=hints_stage) | 191 game = game_class(resource_loader, states, stage_num, rank, difficulty, common, prng=prng, hints=hints_stage) |
192 | 192 |
193 if not enable_particles: | 193 if not enable_particles: |
194 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): | 194 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): |
195 pass | 195 pass |
196 game.new_particle = new_particle | 196 game.new_particle = new_particle |
206 break | 206 break |
207 except NextStage: | 207 except NextStage: |
208 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): | 208 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): |
209 break | 209 break |
210 stage_num += 1 | 210 stage_num += 1 |
211 states = [player.state.copy() for player in game.players] # if player.state.lives >= 0] | 211 states = [player.state for player in game.players] |
212 except GameOver: | 212 except GameOver: |
213 print('Game over') | 213 print('Game over') |
214 break | 214 break |
215 finally: | 215 finally: |
216 if save_filename: | 216 if save_filename: |