comparison eosd @ 422:52829ebe2561

Refactor window management in its own class.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:07:15 +0200
parents b1248bab2d0f
children f41a26971a19
comparison
equal deleted inserted replaced
421:b1248bab2d0f 422:52829ebe2561
52 import logging 52 import logging
53 53
54 import pyximport 54 import pyximport
55 pyximport.install() 55 pyximport.install()
56 56
57 from pytouhou.ui.window import Window
57 from pytouhou.resource.loader import Loader 58 from pytouhou.resource.loader import Loader
58 from pytouhou.game.background import Background 59 from pytouhou.game.background import Background
59 from pytouhou.ui.gamerunner import GameRunner 60 from pytouhou.ui.gamerunner import GameRunner
60 from pytouhou.games.eosd import EoSDGame 61 from pytouhou.games.eosd import EoSDGame
61 from pytouhou.game.game import GameOver 62 from pytouhou.game.game import GameOver
105 resource_loader.scan_archives(data) 106 resource_loader.scan_archives(data)
106 except IOError: 107 except IOError:
107 sys.stderr.write('Some data files were not found, did you forget the -p option?\n') 108 sys.stderr.write('Some data files were not found, did you forget the -p option?\n')
108 exit(1) 109 exit(1)
109 110
111 window = Window(double_buffer=(not single_buffer), fps_limit=fps_limit, fixed_pipeline=fixed_pipeline)
112
110 if stage_num is None: 113 if stage_num is None:
111 story = True 114 story = True
112 stage_num = 1 115 stage_num = 1
113 continues = 3 116 continues = 3
114 else: 117 else:
143 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] 146 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1]
144 states = [PlayerState(character=character, power=default_power)] 147 states = [PlayerState(character=character, power=default_power)]
145 148
146 game_class = EoSDGameBossRush if boss_rush else EoSDGame 149 game_class = EoSDGameBossRush if boss_rush else EoSDGame
147 150
148 runner = GameRunner(resource_loader, fps_limit=fps_limit, double_buffer=(not single_buffer), fixed_pipeline=fixed_pipeline, skip=skip_replay) 151 runner = GameRunner(window, resource_loader, skip=skip_replay)
149 while True: 152 while True:
150 if replay: 153 if replay:
151 level = replay.levels[stage_num - 1] 154 level = replay.levels[stage_num - 1]
152 if not level: 155 if not level:
153 raise Exception 156 raise Exception
198 else: 201 else:
199 background = None 202 background = None
200 203
201 # Main loop 204 # Main loop
202 runner.load_game(game, background, stage.bgms, replay, save_keystates) 205 runner.load_game(game, background, stage.bgms, replay, save_keystates)
206 window.set_runner(runner)
203 try: 207 try:
204 runner.start() 208 window.run()
205 break 209 break
206 except NextStage: 210 except NextStage:
207 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): 211 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5):
208 break 212 break
209 stage_num += 1 213 stage_num += 1