Mercurial > touhou
annotate eosd @ 492:887de1309491
Add friendly fire in netplay.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 21 Sep 2013 20:26:39 +0200 |
parents | 711c75115675 |
children | 6be9c99a3a24 |
rev | line source |
---|---|
414
b0b8825296d0
Follow the PEP-0394 guidelines, migrating from python to python2.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
407
diff
changeset
|
1 #!/usr/bin/env python2 |
52
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
2 # -*- encoding: utf-8 -*- |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
3 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
4 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
5 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
6 ## This program is free software; you can redistribute it and/or modify |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
7 ## it under the terms of the GNU General Public License as published |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
8 ## by the Free Software Foundation; version 3 only. |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
9 ## |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
10 ## This program is distributed in the hope that it will be useful, |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
13 ## GNU General Public License for more details. |
ab826bc29aa2
Add some documentation, GPLv3 headers, README and COPYING file.
Thibaut Girka <thib@sitedethib.com>
parents:
50
diff
changeset
|
14 ## |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
15 |
186
84da28ae7ee4
Parse command line with argparse.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
162
diff
changeset
|
16 import argparse |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
17 import os |
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
18 |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
19 |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
20 pathsep = os.path.pathsep |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
21 default_data = (pathsep.join(('CM.DAT', 'th06*_CM.DAT', '*CM.DAT', '*cm.dat')), |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
22 pathsep.join(('ST.DAT', 'th6*ST.DAT', '*ST.DAT', '*st.dat')), |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
23 pathsep.join(('IN.DAT', 'th6*IN.DAT', '*IN.DAT', '*in.dat')), |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
24 pathsep.join(('MD.DAT', 'th6*MD.DAT', '*MD.DAT', '*md.dat')), |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
25 pathsep.join(('102h.exe', '102*.exe', '東方紅魔郷.exe', '*.exe'))) |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
26 |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
27 |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
28 parser = argparse.ArgumentParser(description='Libre reimplementation of the Touhou 6 engine.') |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
130
diff
changeset
|
29 |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
30 parser.add_argument('data', metavar='DAT', default=default_data, nargs='*', help='Game’s data files') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
31 parser.add_argument('-p', '--path', metavar='DIRECTORY', default='.', help='Game directory path.') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
32 parser.add_argument('-s', '--stage', metavar='STAGE', type=int, default=None, help='Stage, 1 to 7 (Extra).') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
33 parser.add_argument('-r', '--rank', metavar='RANK', type=int, default=0, help='Rank, from 0 (Easy, default) to 3 (Lunatic).') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
34 parser.add_argument('-c', '--character', metavar='CHARACTER', type=int, default=0, help='Select the character to use, from 0 (ReimuA, default) to 3 (MarisaB).') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
35 parser.add_argument('--replay', metavar='REPLAY', help='Select a replay') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
36 parser.add_argument('--save-replay', metavar='REPLAY', help='Save the upcoming game into a replay file') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
37 parser.add_argument('--skip-replay', action='store_true', help='Skip the replay and start to play when it’s finished') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
38 parser.add_argument('-b', '--boss-rush', action='store_true', help='Fight only bosses') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
39 parser.add_argument('--single-buffer', action='store_true', help='Disable double buffering') |
452
1f5156093785
By default, only enable fps limiting if vsync doesn't do the job.
Thibaut Girka <thib@sitedethib.com>
parents:
445
diff
changeset
|
40 parser.add_argument('--fps-limit', metavar='FPS', default=-1, type=int, help='Set fps limit. A value of 0 disables fps limiting, while a negative value limits to 60 fps if and only if vsync doesn’t work.') |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
41 parser.add_argument('--debug', action='store_true', help='Set unlimited continues, and perhaps other debug features.') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
42 parser.add_argument('--fixed-pipeline', action='store_true', help='Use the fixed pipeline instead of the new programmable one.') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
43 parser.add_argument('--no-background', action='store_false', help='Disable background display (huge performance boost on slow systems).') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
44 parser.add_argument('--no-particles', action='store_false', help='Disable particles handling (huge performance boost on slow systems).') |
428
f41a26971a19
Remove all Loader uses from outside pytouhou.games, and add a --no-music option to disable bgm.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
422
diff
changeset
|
45 parser.add_argument('--no-music', action='store_false', help='Disable background music.') |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
46 parser.add_argument('--hints', metavar='HINTS', default=None, help='Hints file, to display text while playing.') |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
47 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.') |
454
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
48 parser.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.') |
487
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
49 parser.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use for netplay') |
486 | 50 parser.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address') |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
51 parser.add_argument('--no-friendly-fire', action='store_false', help='Allow friendly-fire during netplay.') |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
52 |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
53 args = parser.parse_args() |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
54 |
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
55 |
338
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
56 import sys |
363
cb1460b9b6cf
Enable debug messages when using --debug
Thibaut Girka <thib@sitedethib.com>
parents:
352
diff
changeset
|
57 import logging |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
58 |
460
ec327e58b477
Add a context manager to initialize and shut down SDL outside of Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
454
diff
changeset
|
59 from pytouhou.lib.sdl import SDL |
422
52829ebe2561
Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
421
diff
changeset
|
60 from pytouhou.ui.window import Window |
97 | 61 from pytouhou.resource.loader import Loader |
205
ee6dfd14a785
Rename pytouhou.opengl to pytouhou.ui, makes much more sense that way.
Thibaut Girka <thib@sitedethib.com>
parents:
196
diff
changeset
|
62 from pytouhou.ui.gamerunner import GameRunner |
445
b0abb05811f7
Make pytouhou.game.player an extension type, and move the GameOver exception there since it makes more sense.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
434
diff
changeset
|
63 from pytouhou.game.player import PlayerState, GameOver |
373
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
64 from pytouhou.formats.t6rp import T6RP, Level |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
65 from pytouhou.utils.random import Random |
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
66 from pytouhou.vm.msgrunner import NextStage |
404
6c0cb3eee33e
Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
378
diff
changeset
|
67 from pytouhou.formats.hint import Hint |
486 | 68 from pytouhou.network import Network |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
69 |
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
70 |
454
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
71 if args.game == 'EoSD': |
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
72 from pytouhou.games.eosd import EoSDCommon as Common, EoSDGame as Game |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
73 |
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
74 |
454
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
75 class GameBossRush(Game): |
332 | 76 def run_iter(self, keystate): |
337
bc162f60f0a0
Skip dialogs in the boss rush mode, and make boss rush skipping faster
Thibaut Girka <thib@sitedethib.com>
parents:
334
diff
changeset
|
77 for i in range(20): |
344
eab591728abf
Minor fix in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
341
diff
changeset
|
78 skip = not (self.enemies or self.items or self.lasers |
eab591728abf
Minor fix in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
341
diff
changeset
|
79 or self.bullets or self.cancelled_bullets) |
eab591728abf
Minor fix in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
341
diff
changeset
|
80 if skip: |
eab591728abf
Minor fix in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
341
diff
changeset
|
81 keystate &= ~1 |
454
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
82 Game.run_iter(self, keystate | 256 if i == 0 else 0) |
340
39bc59953dfa
Increase player's power stats during skipped frames in boss rush mode.
Thibaut Girka <thib@sitedethib.com>
parents:
339
diff
changeset
|
83 if not self.enemies and self.frame % 90 == 0: |
39bc59953dfa
Increase player's power stats during skipped frames in boss rush mode.
Thibaut Girka <thib@sitedethib.com>
parents:
339
diff
changeset
|
84 for player in self.players: |
39bc59953dfa
Increase player's power stats during skipped frames in boss rush mode.
Thibaut Girka <thib@sitedethib.com>
parents:
339
diff
changeset
|
85 if player.state.power < 128: |
39bc59953dfa
Increase player's power stats during skipped frames in boss rush mode.
Thibaut Girka <thib@sitedethib.com>
parents:
339
diff
changeset
|
86 player.state.power += 1 |
344
eab591728abf
Minor fix in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
341
diff
changeset
|
87 if not skip: |
332 | 88 break |
89 | |
90 def cleanup(self): | |
372
704bea2e4360
Use a future-proof ECL parser.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
91 boss_wait = any(ecl_runner.boss_wait for ecl_runner in self.ecl_runners) |
704bea2e4360
Use a future-proof ECL parser.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
92 if not (self.boss or self.msg_wait or boss_wait): |
332 | 93 self.enemies = [enemy for enemy in self.enemies |
416
e23871eddb7a
Importing everything makes the --help slow, call parse_args before the imports.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
415
diff
changeset
|
94 if enemy.boss_callback != -1 or enemy.frame > 1] |
332 | 95 self.lasers = [laser for laser in self.lasers if laser.frame > 1] |
352
cca5843c2e95
Clean up effects left behind by lasers in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
344
diff
changeset
|
96 self.effects = [effect for effect in self.effects |
cca5843c2e95
Clean up effects left behind by lasers in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
344
diff
changeset
|
97 if not hasattr(effect, '_laser') |
cca5843c2e95
Clean up effects left behind by lasers in boss rush mode
Thibaut Girka <thib@sitedethib.com>
parents:
344
diff
changeset
|
98 or effect._laser in self.lasers] |
332 | 99 self.bullets = [bullet for bullet in self.bullets if bullet.frame > 1] |
454
a502887557ac
Add an option to choose which game to play; currently only EoSD is supported.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
452
diff
changeset
|
100 Game.cleanup(self) |
332 | 101 |
102 | |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
103 def main(window, path, data, stage_num, rank, character, replay, save_filename, |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
104 skip_replay, boss_rush, debug, enable_background, enable_particles, |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
105 enable_music, hints, verbosity, port, remote, friendly_fire): |
373
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
106 |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
107 resource_loader = Loader(path) |
338
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
108 |
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
109 try: |
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
110 resource_loader.scan_archives(data) |
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
111 except IOError: |
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
112 sys.stderr.write('Some data files were not found, did you forget the -p option?\n') |
65453340ae95
Print an error when all the needed files aren’t present.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
337
diff
changeset
|
113 exit(1) |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
114 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
115 if stage_num is None: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
116 story = True |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
117 stage_num = 1 |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
118 continues = 3 |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
119 else: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
120 story = False |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
121 continues = 0 |
339
7a05edbab88a
Implement continues when the lives fall bellow 0.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
338
diff
changeset
|
122 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
123 if debug: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
124 if not verbosity: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
125 verbosity = 'DEBUG' |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
126 continues = -1 # Infinite lives |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
127 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
128 if verbosity: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
129 logging.basicConfig(level=logging.__getattribute__(verbosity)) |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
130 |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
131 if replay: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
132 with open(replay, 'rb') as file: |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
133 replay = T6RP.read(file) |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
134 rank = replay.rank |
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
135 character = replay.character |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
136 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
137 save_keystates = None |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
138 if save_filename: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
139 save_replay = T6RP() |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
140 save_replay.rank = rank |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
141 save_replay.character = character |
187
46793ccfedca
Implement replays.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
186
diff
changeset
|
142 |
487
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
143 difficulty = 16 |
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
144 default_power = [0, 64, 128, 128, 128, 128, 0][stage_num - 1] |
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
145 |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
146 if port != 0: |
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
147 if remote: |
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
148 remote_addr, remote_port = remote.split(':') |
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
149 addr = remote_addr, int(remote_port) |
479
1de67f332f00
Fix several synchro issues
Thibaut Girka <thib@sitedethib.com>
parents:
476
diff
changeset
|
150 selected_player = 0 |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
151 else: |
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
152 addr = None |
479
1de67f332f00
Fix several synchro issues
Thibaut Girka <thib@sitedethib.com>
parents:
476
diff
changeset
|
153 selected_player = 1 |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
154 |
476 | 155 prng = Random(0) |
479
1de67f332f00
Fix several synchro issues
Thibaut Girka <thib@sitedethib.com>
parents:
476
diff
changeset
|
156 con = Network(port, addr, selected_player) |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
157 states = [PlayerState(0, character=1, power=default_power, continues=continues), |
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
158 PlayerState(1, character=3, power=default_power, continues=continues)] |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
159 else: |
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
160 con = None |
487
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
161 selected_player = 0 |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
162 states = [PlayerState(0, character=character, power=default_power, continues=continues)] |
475
9d4d52793eca
Experimental netplay! Yay!
Thibaut Girka <thib@sitedethib.com>
parents:
224
diff
changeset
|
163 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
164 if hints: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
165 with open(hints, 'rb') as file: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
166 hints = Hint.read(file) |
404
6c0cb3eee33e
Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
378
diff
changeset
|
167 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
168 game_class = GameBossRush if boss_rush else Game |
332 | 169 |
487
711c75115675
Various netplay-related fixes.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
486
diff
changeset
|
170 common = Common(resource_loader, states[selected_player]) |
486 | 171 runner = GameRunner(window, resource_loader, skip=skip_replay, con=con) |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
172 while True: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
173 if replay: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
174 level = replay.levels[stage_num - 1] |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
175 if not level: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
176 raise Exception |
262
8fa660da5f0c
Automatically search data files using different names.
Thibaut Girka <thib@sitedethib.com>
parents:
231
diff
changeset
|
177 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
178 prng = Random(level.random_seed) |
83
fc0294c745b6
Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents:
72
diff
changeset
|
179 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
180 #TODO: apply the replay to the other players. |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
181 #TODO: see if the stored score is used or if it’s the one from the previous stage. |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
182 if stage_num != 1 and stage_num - 2 in replay.levels: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
183 previous_level = replay.levels[stage_num - 1] |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
184 states[0].score = previous_level.score |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
185 states[0].effective_score = previous_level.score |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
186 states[0].points = level.point_items |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
187 states[0].power = level.power |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
188 states[0].lives = level.lives |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
189 states[0].bombs = level.bombs |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
190 difficulty = level.difficulty |
486 | 191 elif port == 0: |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
192 prng = Random() |
83
fc0294c745b6
Basic bullet handling! Clean up as soon as possible :p
Thibaut Girka <thib@sitedethib.com>
parents:
72
diff
changeset
|
193 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
194 if save_filename: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
195 if not replay: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
196 save_replay.levels[stage_num - 1] = level = Level() |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
197 level.score = states[0].score |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
198 level.random_seed = prng.seed |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
199 level.point_items = states[0].points |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
200 level.power = states[0].power |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
201 level.lives = states[0].lives |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
202 level.bombs = states[0].bombs |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
203 level.difficulty = difficulty |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
204 save_keystates = [] |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
205 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
206 hints_stage = hints.stages[stage_num - 1] if hints else None |
404
6c0cb3eee33e
Add MoF’s hints support, and fix the Text timeout interface.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
378
diff
changeset
|
207 |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
208 game = game_class(resource_loader, states, stage_num, rank, difficulty, |
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
209 common, prng=prng, hints=hints_stage, |
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
210 friendly_fire=friendly_fire) |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
211 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
212 if not enable_particles: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
213 def new_particle(pos, anim, amp, number=1, reverse=False, duration=24): |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
214 pass |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
215 game.new_particle = new_particle |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
216 |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
217 background = game.background if enable_background else None |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
218 bgms = game.std.bgms if enable_music else None |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
219 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
220 # Main loop |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
221 runner.load_game(game, background, bgms, replay, save_keystates) |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
222 window.set_runner(runner) |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
223 try: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
224 window.run() |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
225 break |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
226 except NextStage: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
227 if not story or stage_num == (7 if boss_rush else 6 if rank > 0 else 5): |
331
1b4f04b08729
Add the story mode.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
321
diff
changeset
|
228 break |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
229 stage_num += 1 |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
230 states = [player.state for player in game.players] |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
231 except GameOver: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
232 print('Game over') |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
233 break |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
234 finally: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
235 if save_filename: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
236 last_key = -1 |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
237 for time, key in enumerate(save_keystates): |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
238 if key != last_key: |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
239 level.keys.append((time, key, 0)) |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
240 last_key = key |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
241 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
242 window.set_runner(None) |
373
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
243 |
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
244 if save_filename: |
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
245 with open(save_filename, 'wb+') as file: |
6deab6ad8be8
Add the ability to save a replay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
372
diff
changeset
|
246 save_replay.write(file) |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
247 |
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
248 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
249 with SDL(): |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
250 window = Window(double_buffer=(not args.single_buffer), |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
251 fps_limit=args.fps_limit, |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
252 fixed_pipeline=args.fixed_pipeline) |
18
ca26a84916cb
Add preliminary ECL viewer/interpreter.
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
253 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
254 main(window, args.path, tuple(args.data), args.stage, args.rank, |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
255 args.character, args.replay, args.save_replay, args.skip_replay, |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
256 args.boss_rush, args.debug, args.no_background, args.no_particles, |
492
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
257 args.no_music, args.hints, args.verbosity, args.port, args.remote, |
887de1309491
Add friendly fire in netplay.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
487
diff
changeset
|
258 args.no_friendly_fire) |
186
84da28ae7ee4
Parse command line with argparse.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
162
diff
changeset
|
259 |
469
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
260 import gc |
58b47e788c59
Move SDL context-manager and Window creation outside of main.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
465
diff
changeset
|
261 gc.collect() |