Mercurial > pyntnclick
comparison gamelib/main.py @ 176:c6ea3b11514c
Add --scene for selecting initial scene during debugging.
author | Simon Cross <simon@simonx> |
---|---|
date | Wed, 25 Aug 2010 13:56:38 +0200 |
parents | 7f6b11a0d404 |
children | 3cedc4f95925 |
comparison
equal
deleted
inserted
replaced
175:3d3efc5648cc | 176:c6ea3b11514c |
---|---|
17 from albow.dialogs import alert | 17 from albow.dialogs import alert |
18 from albow.shell import Shell | 18 from albow.shell import Shell |
19 | 19 |
20 from menu import MenuScreen | 20 from menu import MenuScreen |
21 from gamescreen import GameScreen | 21 from gamescreen import GameScreen |
22 from constants import SCREEN, FRAME_RATE, FREQ, BITSIZE, CHANNELS, BUFFER | 22 from constants import SCREEN, FRAME_RATE, FREQ, BITSIZE, CHANNELS, BUFFER, DEBUG |
23 from sound import no_sound, disable_sound | 23 from sound import no_sound, disable_sound |
24 import state | |
24 | 25 |
25 def parse_args(args): | 26 def parse_args(args): |
26 parser = OptionParser() | 27 parser = OptionParser() |
27 parser.add_option("--no-sound", action="store_false", default=True, | 28 parser.add_option("--no-sound", action="store_false", default=True, |
28 dest="sound", help="disable sound") | 29 dest="sound", help="disable sound") |
30 if DEBUG: | |
31 parser.add_option("--scene", type="str", default=None, | |
32 dest="scene", help="initial scene") | |
29 opts, _ = parser.parse_args(args or []) | 33 opts, _ = parser.parse_args(args or []) |
30 return opts | 34 return opts |
31 | 35 |
32 | 36 |
33 class MainShell(Shell): | 37 class MainShell(Shell): |
48 except pygame.error, exc: | 52 except pygame.error, exc: |
49 no_sound(exc) | 53 no_sound(exc) |
50 else: | 54 else: |
51 # Ensure get_sound returns nothing, so everything else just works | 55 # Ensure get_sound returns nothing, so everything else just works |
52 disable_sound() | 56 disable_sound() |
57 if DEBUG and opts.scene is not None: | |
58 # debug the specified scene | |
59 state.DEBUG_SCENE = opts.scene | |
53 display = pygame.display.set_mode(SCREEN, SWSURFACE) | 60 display = pygame.display.set_mode(SCREEN, SWSURFACE) |
54 shell = MainShell(display) | 61 shell = MainShell(display) |
55 try: | 62 try: |
56 shell.run() | 63 shell.run() |
57 except KeyboardInterrupt: | 64 except KeyboardInterrupt: |