Mercurial > touhou
comparison eosd @ 339:7a05edbab88a
Implement continues when the lives fall bellow 0.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 04 Jul 2012 21:38:00 +0200 |
parents | 65453340ae95 |
children | 39bc59953dfa |
comparison
equal
deleted
inserted
replaced
338:65453340ae95 | 339:7a05edbab88a |
---|---|
22 | 22 |
23 from pytouhou.resource.loader import Loader | 23 from pytouhou.resource.loader import Loader |
24 from pytouhou.game.background import Background | 24 from pytouhou.game.background import Background |
25 from pytouhou.ui.gamerunner import GameRunner | 25 from pytouhou.ui.gamerunner import GameRunner |
26 from pytouhou.games.eosd import EoSDGame | 26 from pytouhou.games.eosd import EoSDGame |
27 from pytouhou.game.game import GameOver | |
27 from pytouhou.game.player import PlayerState | 28 from pytouhou.game.player import PlayerState |
28 from pytouhou.formats.t6rp import T6RP | 29 from pytouhou.formats.t6rp import T6RP |
29 from pytouhou.utils.random import Random | 30 from pytouhou.utils.random import Random |
30 from pytouhou.vm.msgrunner import NextStage | 31 from pytouhou.vm.msgrunner import NextStage |
31 | 32 |
48 self.players_bullets = [bullet for bullet in self.players_bullets if bullet.frame > 1] | 49 self.players_bullets = [bullet for bullet in self.players_bullets if bullet.frame > 1] |
49 EoSDGame.cleanup(self) | 50 EoSDGame.cleanup(self) |
50 | 51 |
51 | 52 |
52 | 53 |
53 def main(path, data, stage_num, rank, character, replay, boss_rush, fps_limit, single_buffer): | 54 def main(path, data, stage_num, rank, character, replay, boss_rush, fps_limit, single_buffer, debug): |
54 resource_loader = Loader(path) | 55 resource_loader = Loader(path) |
55 | 56 |
56 try: | 57 try: |
57 resource_loader.scan_archives(data) | 58 resource_loader.scan_archives(data) |
58 except IOError: | 59 except IOError: |
60 exit(1) | 61 exit(1) |
61 | 62 |
62 if stage_num is None: | 63 if stage_num is None: |
63 story = True | 64 story = True |
64 stage_num = 1 | 65 stage_num = 1 |
66 continues = 3 | |
65 else: | 67 else: |
66 story = False | 68 story = False |
69 continues = 0 | |
70 | |
71 if debug: | |
72 continues = float('inf') | |
67 | 73 |
68 if replay: | 74 if replay: |
69 with open(replay, 'rb') as file: | 75 with open(replay, 'rb') as file: |
70 replay = T6RP.read(file) | 76 replay = T6RP.read(file) |
71 rank = replay.rank | 77 rank = replay.rank |
100 prng = None | 106 prng = None |
101 | 107 |
102 # Load stage data | 108 # Load stage data |
103 stage = resource_loader.get_stage('stage%d.std' % stage_num) | 109 stage = resource_loader.get_stage('stage%d.std' % stage_num) |
104 | 110 |
105 game = game_class(resource_loader, states, stage_num, rank, difficulty, prng=prng, bgms=stage.bgms) | 111 game = game_class(resource_loader, states, stage_num, rank, difficulty, prng=prng, bgms=stage.bgms, continues=continues) |
106 | 112 |
107 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) | 113 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) |
108 background = Background(stage, background_anm_wrapper) | 114 background = Background(stage, background_anm_wrapper) |
109 | 115 |
110 # Main loop | 116 # Main loop |
116 game.music.pause() | 122 game.music.pause() |
117 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): | 123 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): |
118 break | 124 break |
119 stage_num += 1 | 125 stage_num += 1 |
120 states = [player.state.copy() for player in game.players] # if player.state.lives >= 0] | 126 states = [player.state.copy() for player in game.players] # if player.state.lives >= 0] |
127 except GameOver: | |
128 print('Game over') | |
129 break | |
121 | 130 |
122 | 131 |
123 pathsep = os.path.pathsep | 132 pathsep = os.path.pathsep |
124 default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')), | 133 default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')), |
125 pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')), | 134 pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')), |
137 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') | 146 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') |
138 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') | 147 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') |
139 parser.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses') | 148 parser.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses') |
140 parser.add_argument('--single-buffer', action='store_true', help='Disable double buffering') | 149 parser.add_argument('--single-buffer', action='store_true', help='Disable double buffering') |
141 parser.add_argument('--fps-limit', metavar='FPS', default=60, type=int, help='Set fps limit') | 150 parser.add_argument('--fps-limit', metavar='FPS', default=60, type=int, help='Set fps limit') |
151 parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.') | |
142 | 152 |
143 args = parser.parse_args() | 153 args = parser.parse_args() |
144 | 154 |
145 main(args.path, tuple(args.data), args.stage, args.rank, args.character, | 155 main(args.path, tuple(args.data), args.stage, args.rank, args.character, |
146 args.replay, args.boss_rush, args.fps_limit, args.single_buffer) | 156 args.replay, args.boss_rush, args.fps_limit, args.single_buffer, |
157 args.debug) |