Mercurial > boomslang
changeset 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 | eb3cfcaff469 |
children | 3ac2e025478f |
files | gamelib/main.py gamelib/state.py |
diffstat | 2 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/gamelib/main.py Fri Aug 27 23:01:17 2010 +0200 +++ b/gamelib/main.py Fri Aug 27 23:09:07 2010 +0200 @@ -29,6 +29,8 @@ if DEBUG: parser.add_option("--scene", type="str", default=None, dest="scene", help="initial scene") + parser.add_option("--no-rects", action="store_false", default=True, + dest="rects", help="disable debugging rects") opts, _ = parser.parse_args(args or []) return opts @@ -53,9 +55,11 @@ 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 + if DEBUG: + if opts.scene is not None: + # debug the specified scene + state.DEBUG_SCENE = opts.scene + state.DEBUG_RECTS = opts.rects display = pygame.display.set_mode(SCREEN, SWSURFACE) shell = MainShell(display) try:
--- a/gamelib/state.py Fri Aug 27 23:01:17 2010 +0200 +++ b/gamelib/state.py Fri Aug 27 23:09:07 2010 +0200 @@ -12,6 +12,9 @@ # override the initial scene to for debugging DEBUG_SCENE = None +# whether to show debugging rects +DEBUG_RECTS = False + class Result(object): """Result of interacting with a thing""" @@ -362,10 +365,7 @@ # Interact rectangle hi-light color (for debugging) # (set to None to turn off) - if constants.DEBUG: - _interact_hilight_color = Color('red') - else: - _interact_hilight_color = None + _interact_hilight_color = Color('red') def __init__(self): StatefulGizmo.__init__(self) @@ -461,7 +461,7 @@ self.current_interact.rect = old_rect.move(self.scene.OFFSET) self.current_interact.draw(surface) self.current_interact.rect = old_rect - if self._interact_hilight_color is not None: + if DEBUG_RECTS: if hasattr(self.rect, 'collidepoint'): frame_rect(surface, self._interact_hilight_color, self.rect.inflate(1, 1), 1)