# HG changeset patch # User Simon Cross # Date 1282588478 -7200 # Node ID 158a13a48d481d93b2c0159717e0af058f4e5e32 # Parent 6b0f7364f3bfbf871dad7bae587a1cc8f2eb96de Show interact rectangles when constants.DEBUG is True. diff -r 6b0f7364f3bf -r 158a13a48d48 gamelib/constants.py --- a/gamelib/constants.py Mon Aug 23 20:18:29 2010 +0200 +++ b/gamelib/constants.py Mon Aug 23 20:34:38 2010 +0200 @@ -8,3 +8,5 @@ BUFFER = 1024 # audio buffer size in no. of samples BUTTON_SIZE = 50 + +DEBUG = True diff -r 6b0f7364f3bf -r 158a13a48d48 gamelib/state.py --- a/gamelib/state.py Mon Aug 23 20:18:29 2010 +0200 +++ b/gamelib/state.py Mon Aug 23 20:34:38 2010 +0200 @@ -1,8 +1,12 @@ """Utilities and base classes for dealing with scenes.""" from albow.resource import get_image, get_sound +from albow.utils import frame_rect from pygame.locals import BLEND_ADD from pygame.rect import Rect +from pygame.color import Color + +import constants def initial_state(): @@ -162,11 +166,20 @@ # name of image resource IMAGE = None + # 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 + def __init__(self, name, rect): StatefulGizmo.__init__(self) self.name = name + # area within scene to render to + self.rect = Rect(rect) # area within scene that triggers calls to interact - self.rect = rect + self.interact_rect = Rect(rect) # these are set by set_scene self.scene = None self.state = None @@ -206,7 +219,10 @@ self.message("It doesn't work.") def draw(self, surface): - pass + if self._interact_hilight_color is not None: + frame_rect(surface, self._interact_hilight_color, + self.interact_rect.inflate(1, 1), 1) + # TODO: draw image if there is one class Item(object):