Mercurial > touhou
comparison eosd @ 434:18e4b121646b
Move the common parts of EoSDGame outside, to not reallocate them at each stage.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 11 Aug 2013 14:30:52 +0200 |
parents | 77c0e9a53795 |
children | b0abb05811f7 |
comparison
equal
deleted
inserted
replaced
433:1222341ea22c | 434:18e4b121646b |
---|---|
53 import logging | 53 import logging |
54 | 54 |
55 from pytouhou.ui.window import Window | 55 from pytouhou.ui.window import Window |
56 from pytouhou.resource.loader import Loader | 56 from pytouhou.resource.loader import Loader |
57 from pytouhou.ui.gamerunner import GameRunner | 57 from pytouhou.ui.gamerunner import GameRunner |
58 from pytouhou.games.eosd import EoSDGame | 58 from pytouhou.games.eosd import EoSDCommon, EoSDGame |
59 from pytouhou.game.game import GameOver | 59 from pytouhou.game.game import GameOver |
60 from pytouhou.game.player import PlayerState | 60 from pytouhou.game.player import PlayerState |
61 from pytouhou.formats.t6rp import T6RP, Level | 61 from pytouhou.formats.t6rp import T6RP, Level |
62 from pytouhou.utils.random import Random | 62 from pytouhou.utils.random import Random |
63 from pytouhou.vm.msgrunner import NextStage | 63 from pytouhou.vm.msgrunner import NextStage |
143 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] | 143 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] |
144 states = [PlayerState(character=character, power=default_power)] | 144 states = [PlayerState(character=character, power=default_power)] |
145 | 145 |
146 game_class = EoSDGameBossRush if boss_rush else EoSDGame | 146 game_class = EoSDGameBossRush if boss_rush else EoSDGame |
147 | 147 |
148 common = EoSDCommon(resource_loader) | |
148 runner = GameRunner(window, resource_loader, skip=skip_replay) | 149 runner = GameRunner(window, resource_loader, skip=skip_replay) |
149 while True: | 150 while True: |
150 if replay: | 151 if replay: |
151 level = replay.levels[stage_num - 1] | 152 level = replay.levels[stage_num - 1] |
152 if not level: | 153 if not level: |
180 level.difficulty = difficulty | 181 level.difficulty = difficulty |
181 save_keystates = [] | 182 save_keystates = [] |
182 | 183 |
183 hints_stage = hints.stages[stage_num - 1] if hints else None | 184 hints_stage = hints.stages[stage_num - 1] if hints else None |
184 | 185 |
185 game = game_class(resource_loader, states, stage_num, rank, difficulty, prng=prng, continues=continues, hints=hints_stage) | 186 game = game_class(resource_loader, states, stage_num, rank, difficulty, common, prng=prng, continues=continues, hints=hints_stage) |
186 | 187 |
187 if not enable_particles: | 188 if not enable_particles: |
188 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): | 189 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): |
189 pass | 190 pass |
190 game.new_particle = new_particle | 191 game.new_particle = new_particle |