changeset 68:158a13a48d48

Show interact rectangles when constants.DEBUG is True.
author Simon Cross <hodgestar+bzr@gmail.com>
date Mon, 23 Aug 2010 20:34:38 +0200
parents 6b0f7364f3bf
children d4bbb26099cc
files gamelib/constants.py gamelib/state.py
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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):