diff gamelib/statehelpers.py @ 182:5cb3fbe61f75

Add genric thing with description helper class
author Neil Muller <neil@dip.sun.ac.za>
date Wed, 25 Aug 2010 15:45:45 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gamelib/statehelpers.py	Wed Aug 25 15:45:45 2010 +0200
@@ -0,0 +1,30 @@
+"""Set of utility classes for common state things"""
+
+from pygame.color import Color
+from pygame.colordict import THECOLORS
+
+from gamelib.state import Thing, Result, \
+                          InteractImage, InteractNoImage, InteractRectUnion, \
+                          InteractAnimated
+from gamelib.constants import DEBUG
+
+
+class GenericDescThing(Thing):
+    "Thing with an InteractiveUnionRect and a description"
+
+    INITIAL = "description"
+
+    def __init__(self, prefix, number, description, areas):
+        super(GenericDescThing, self).__init__()
+        self.description = description
+        self.name = '%s.%s' % (prefix, number)
+        self.interacts = {
+                'description' : InteractRectUnion(areas)
+                }
+        if DEBUG:
+            # Individual colors to make debugging easier
+            self._interact_hilight_color = Color(THECOLORS.keys()[number])
+
+    def get_description(self):
+        return self.description
+