Mercurial > pyntnclick
changeset 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 | 3d3efc5648cc |
children | fd9e84efe325 |
files | gamelib/main.py gamelib/state.py |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/main.py Wed Aug 25 13:55:20 2010 +0200 +++ b/gamelib/main.py Wed Aug 25 13:56:38 2010 +0200 @@ -19,13 +19,17 @@ from menu import MenuScreen from gamescreen import GameScreen -from constants import SCREEN, FRAME_RATE, FREQ, BITSIZE, CHANNELS, BUFFER +from constants import SCREEN, FRAME_RATE, FREQ, BITSIZE, CHANNELS, BUFFER, DEBUG from sound import no_sound, disable_sound +import state def parse_args(args): parser = OptionParser() parser.add_option("--no-sound", action="store_false", default=True, dest="sound", help="disable sound") + if DEBUG: + parser.add_option("--scene", type="str", default=None, + dest="scene", help="initial scene") opts, _ = parser.parse_args(args or []) return opts @@ -50,6 +54,9 @@ else: # Ensure get_sound returns nothing, so everything else just works disable_sound() + if DEBUG and opts.scene is not None: + # debug the specified scene + state.DEBUG_SCENE = opts.scene display = pygame.display.set_mode(SCREEN, SWSURFACE) shell = MainShell(display) try:
--- a/gamelib/state.py Wed Aug 25 13:55:20 2010 +0200 +++ b/gamelib/state.py Wed Aug 25 13:56:38 2010 +0200 @@ -12,6 +12,8 @@ from sound import get_sound from cursor import HAND +# override the initial scene to for debugging +DEBUG_SCENE = None class Result(object): """Result of interacting with a thing""" @@ -41,7 +43,8 @@ state.load_scenes("engine") state.load_scenes("machine") state.load_scenes("map") - state.set_current_scene("cryo") + initial_scene = "cryo" if DEBUG_SCENE is None else DEBUG_SCENE + state.set_current_scene(initial_scene) state.set_do_enter_leave() return state