diff skaapsteker/sprites/base.py @ 127:e1dd3b785269

Initial game state stuff.
author Jeremy Thurgood <firxen@gmail.com>
date Tue, 05 Apr 2011 00:03:33 +0200
parents 51bcc909873d
children 6b488e1351a5
line wrap: on
line diff
--- a/skaapsteker/sprites/base.py	Mon Apr 04 23:38:03 2011 +0200
+++ b/skaapsteker/sprites/base.py	Tue Apr 05 00:03:33 2011 +0200
@@ -48,6 +48,24 @@
     mobile = False
     gravitates = False
 
+    image_file = None
+    collision_layer = MONSTER_LAYER
+    collides_with = set([PC_LAYER])
+
+    debug_color = (240, 0, 240)
+
+    def __init__(self, pos, **opts):
+        Sprite.__init__(self)
+        self.image = data.load_image('sprites/' + self.image_file)
+        self.starting_tile_pos = pos
+        self.rect = self.image.get_rect(topleft=(pos[0]*TILE_SIZE[0], pos[1]*TILE_SIZE[1]))
+        self._layer = Layers.PLAYER
+        self.setup(**opts)
+
+
+    def setup(self):
+        pass
+
 
 class Geography(Sprite):
     mobile = False
@@ -70,11 +88,12 @@
         return (0, 240, 0)
 
 
-def find_sprite(descr):
+def find_sprite(descr, mod_name=None):
     """Create a sprite object from a dictionary describing it."""
     descr = descr.copy()
-    stype = descr.pop("type")
-    mod_name, cls_name = stype.rsplit(".", 1)
+    cls_name = descr.pop("type")
+    if mod_name is None:
+        mod_name, cls_name = cls_name.rsplit(".", 1)
     mod_name = ".".join(["skaapsteker.sprites", mod_name])
     mod =  __import__(mod_name, fromlist=[cls_name])
     cls = getattr(mod, cls_name)