comparison eosd @ 503:c622eaf64428

Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 04 Oct 2013 14:27:11 +0200
parents 777544d11578
children 1bc014f9d572
comparison
equal deleted inserted replaced
502:3d3285918ba1 503:c622eaf64428
164 hints = Hint.read(file) 164 hints = Hint.read(file)
165 165
166 game_class = GameBossRush if boss_rush else Game 166 game_class = GameBossRush if boss_rush else Game
167 167
168 common = Common(resource_loader, characters, continues, stage_num - 1) 168 common = Common(resource_loader, characters, continues, stage_num - 1)
169 runner = GameRunner(window, resource_loader, skip=skip_replay, con=con) 169 runner = GameRunner(window, common, resource_loader, skip_replay, con)
170 window.set_runner(runner)
170 while True: 171 while True:
171 first_player = common.players[0] 172 first_player = common.players[0]
172 173
173 if replay: 174 if replay:
174 level = replay.levels[stage_num - 1] 175 level = replay.levels[stage_num - 1]
204 save_keystates = [] 205 save_keystates = []
205 206
206 hints_stage = hints.stages[stage_num - 1] if hints else None 207 hints_stage = hints.stages[stage_num - 1] if hints else None
207 208
208 game = game_class(resource_loader, stage_num, rank, difficulty, 209 game = game_class(resource_loader, stage_num, rank, difficulty,
209 common, prng=prng, hints=hints_stage, 210 common, prng, hints_stage, friendly_fire)
210 friendly_fire=friendly_fire)
211 211
212 if not enable_particles: 212 if not enable_particles:
213 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): 213 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24):
214 pass 214 pass
215 game.new_particle = new_particle 215 game.new_particle = new_particle
217 background = game.background if enable_background else None 217 background = game.background if enable_background else None
218 bgms = game.std.bgms if enable_music else None 218 bgms = game.std.bgms if enable_music else None
219 219
220 # Main loop 220 # Main loop
221 runner.load_game(game, background, bgms, replay, save_keystates) 221 runner.load_game(game, background, bgms, replay, save_keystates)
222 window.set_runner(runner)
223 try: 222 try:
224 window.run() 223 window.run()
225 break 224 break
226 except NextStage: 225 except NextStage:
227 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): 226 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5):