comparison gamelib/state.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 d9b19449436f
children 75783238f73d
comparison
equal deleted inserted replaced
281:eb3cfcaff469 282:fe899fb63866
9 import constants 9 import constants
10 from sound import get_sound 10 from sound import get_sound
11 11
12 # override the initial scene to for debugging 12 # override the initial scene to for debugging
13 DEBUG_SCENE = None 13 DEBUG_SCENE = None
14
15 # whether to show debugging rects
16 DEBUG_RECTS = False
14 17
15 class Result(object): 18 class Result(object):
16 """Result of interacting with a thing""" 19 """Result of interacting with a thing"""
17 20
18 def __init__(self, message=None, soundfile=None, detail_view=None, style=None): 21 def __init__(self, message=None, soundfile=None, detail_view=None, style=None):
360 # name first interact 363 # name first interact
361 INITIAL = None 364 INITIAL = None
362 365
363 # Interact rectangle hi-light color (for debugging) 366 # Interact rectangle hi-light color (for debugging)
364 # (set to None to turn off) 367 # (set to None to turn off)
365 if constants.DEBUG: 368 _interact_hilight_color = Color('red')
366 _interact_hilight_color = Color('red')
367 else:
368 _interact_hilight_color = None
369 369
370 def __init__(self): 370 def __init__(self):
371 StatefulGizmo.__init__(self) 371 StatefulGizmo.__init__(self)
372 # name of the thing 372 # name of the thing
373 self.name = self.NAME 373 self.name = self.NAME
459 old_rect = self.current_interact.rect 459 old_rect = self.current_interact.rect
460 if old_rect: 460 if old_rect:
461 self.current_interact.rect = old_rect.move(self.scene.OFFSET) 461 self.current_interact.rect = old_rect.move(self.scene.OFFSET)
462 self.current_interact.draw(surface) 462 self.current_interact.draw(surface)
463 self.current_interact.rect = old_rect 463 self.current_interact.rect = old_rect
464 if self._interact_hilight_color is not None: 464 if DEBUG_RECTS:
465 if hasattr(self.rect, 'collidepoint'): 465 if hasattr(self.rect, 'collidepoint'):
466 frame_rect(surface, self._interact_hilight_color, 466 frame_rect(surface, self._interact_hilight_color,
467 self.rect.inflate(1, 1), 1) 467 self.rect.inflate(1, 1), 1)
468 else: 468 else:
469 for rect in self.rect: 469 for rect in self.rect: