comparison eosd @ 454:a502887557ac

Add an option to choose which game to play; currently only EoSD is supported.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 31 Aug 2013 07:39:04 +0200
parents 1f5156093785
children ec327e58b477
comparison
equal deleted inserted replaced
453:17a7f3b028f3 454:a502887557ac
43 parser.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).') 43 parser.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).')
44 parser.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).') 44 parser.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).')
45 parser.add_argument('--no-music', action='store_false', help='Disable background music.') 45 parser.add_argument('--no-music', action='store_false', help='Disable background music.')
46 parser.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.') 46 parser.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.')
47 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.') 47 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.')
48 parser.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.')
48 49
49 args = parser.parse_args() 50 args = parser.parse_args()
50 51
51 52
52 import sys 53 import sys
53 import logging 54 import logging
54 55
55 from pytouhou.ui.window import Window 56 from pytouhou.ui.window import Window
56 from pytouhou.resource.loader import Loader 57 from pytouhou.resource.loader import Loader
57 from pytouhou.ui.gamerunner import GameRunner 58 from pytouhou.ui.gamerunner import GameRunner
58 from pytouhou.games.eosd import EoSDCommon, EoSDGame
59 from pytouhou.game.player import PlayerState, GameOver 59 from pytouhou.game.player import PlayerState, GameOver
60 from pytouhou.formats.t6rp import T6RP, Level 60 from pytouhou.formats.t6rp import T6RP, Level
61 from pytouhou.utils.random import Random 61 from pytouhou.utils.random import Random
62 from pytouhou.vm.msgrunner import NextStage 62 from pytouhou.vm.msgrunner import NextStage
63 from pytouhou.formats.hint import Hint 63 from pytouhou.formats.hint import Hint
64 64
65 65
66 class EoSDGameBossRush(EoSDGame): 66 if args.game == 'EoSD':
67 from pytouhou.games.eosd import EoSDCommon as Common, EoSDGame as Game
68
69
70 class GameBossRush(Game):
67 def run_iter(self, keystate): 71 def run_iter(self, keystate):
68 for i in range(20): 72 for i in range(20):
69 skip = not (self.enemies or self.items or self.lasers 73 skip = not (self.enemies or self.items or self.lasers
70 or self.bullets or self.cancelled_bullets) 74 or self.bullets or self.cancelled_bullets)
71 if skip: 75 if skip:
72 keystate &= ~1 76 keystate &= ~1
73 EoSDGame.run_iter(self, keystate | 256 if i == 0 else 0) 77 Game.run_iter(self, keystate | 256 if i == 0 else 0)
74 if not self.enemies and self.frame % 90 == 0: 78 if not self.enemies and self.frame % 90 == 0:
75 for player in self.players: 79 for player in self.players:
76 if player.state.power < 128: 80 if player.state.power < 128:
77 player.state.power += 1 81 player.state.power += 1
78 if not skip: 82 if not skip:
86 self.lasers = [laser for laser in self.lasers if laser.frame > 1] 90 self.lasers = [laser for laser in self.lasers if laser.frame > 1]
87 self.effects = [effect for effect in self.effects 91 self.effects = [effect for effect in self.effects
88 if not hasattr(effect, '_laser') 92 if not hasattr(effect, '_laser')
89 or effect._laser in self.lasers] 93 or effect._laser in self.lasers]
90 self.bullets = [bullet for bullet in self.bullets if bullet.frame > 1] 94 self.bullets = [bullet for bullet in self.bullets if bullet.frame > 1]
91 EoSDGame.cleanup(self) 95 Game.cleanup(self)
92 96
93 97
94 def main(path, data, stage_num, rank, character, replay, save_filename, 98 def main(path, data, stage_num, rank, character, replay, save_filename,
95 skip_replay, boss_rush, fps_limit, single_buffer, debug, 99 skip_replay, boss_rush, fps_limit, single_buffer, debug,
96 fixed_pipeline, enable_background, enable_particles, enable_music, 100 fixed_pipeline, enable_background, enable_particles, enable_music,
140 144
141 difficulty = 16 145 difficulty = 16
142 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]
143 states = [PlayerState(character=character, power=default_power)] 147 states = [PlayerState(character=character, power=default_power)]
144 148
145 game_class = EoSDGameBossRush if boss_rush else EoSDGame 149 game_class = GameBossRush if boss_rush else Game
146 150
147 common = EoSDCommon(resource_loader) 151 common = Common(resource_loader)
148 runner = GameRunner(window, resource_loader, skip=skip_replay) 152 runner = GameRunner(window, resource_loader, skip=skip_replay)
149 while True: 153 while True:
150 if replay: 154 if replay:
151 level = replay.levels[stage_num - 1] 155 level = replay.levels[stage_num - 1]
152 if not level: 156 if not level: