comparison gamelib/main.py @ 282:fe899fb63866

Add option for turning off debugging rects while debugging.
author Simon Cross <hodgestar+bzr@gmail.com>
date Fri, 27 Aug 2010 23:09:07 +0200
parents 3cedc4f95925
children 3dab4984cbd7
comparison
equal deleted inserted replaced
281:eb3cfcaff469 282:fe899fb63866
27 parser.add_option("--no-sound", action="store_false", default=True, 27 parser.add_option("--no-sound", action="store_false", default=True,
28 dest="sound", help="disable sound") 28 dest="sound", help="disable sound")
29 if DEBUG: 29 if DEBUG:
30 parser.add_option("--scene", type="str", default=None, 30 parser.add_option("--scene", type="str", default=None,
31 dest="scene", help="initial scene") 31 dest="scene", help="initial scene")
32 parser.add_option("--no-rects", action="store_false", default=True,
33 dest="rects", help="disable debugging rects")
32 opts, _ = parser.parse_args(args or []) 34 opts, _ = parser.parse_args(args or [])
33 return opts 35 return opts
34 36
35 37
36 class MainShell(Shell): 38 class MainShell(Shell):
51 except pygame.error, exc: 53 except pygame.error, exc:
52 no_sound(exc) 54 no_sound(exc)
53 else: 55 else:
54 # Ensure get_sound returns nothing, so everything else just works 56 # Ensure get_sound returns nothing, so everything else just works
55 disable_sound() 57 disable_sound()
56 if DEBUG and opts.scene is not None: 58 if DEBUG:
57 # debug the specified scene 59 if opts.scene is not None:
58 state.DEBUG_SCENE = opts.scene 60 # debug the specified scene
61 state.DEBUG_SCENE = opts.scene
62 state.DEBUG_RECTS = opts.rects
59 display = pygame.display.set_mode(SCREEN, SWSURFACE) 63 display = pygame.display.set_mode(SCREEN, SWSURFACE)
60 shell = MainShell(display) 64 shell = MainShell(display)
61 try: 65 try:
62 shell.run() 66 shell.run()
63 except KeyboardInterrupt: 67 except KeyboardInterrupt: