Mercurial > skaapsteker
diff skaapsteker/sprites/base.py @ 189:9d08f99b5ddf
Add npcs to gamestate. Update gamestate. Pass world around a bit. Some other stuff.
author | Simon Cross <hodgestar@gmail.com> |
---|---|
date | Wed, 06 Apr 2011 21:14:26 +0200 |
parents | 72e92893ccb8 |
children | 993f4f55eb93 |
line wrap: on
line diff
--- a/skaapsteker/sprites/base.py Wed Apr 06 21:02:38 2011 +0200 +++ b/skaapsteker/sprites/base.py Wed Apr 06 21:14:26 2011 +0200 @@ -5,6 +5,7 @@ from skaapsteker.physics import Sprite from skaapsteker.constants import Layers from skaapsteker import data +from skaapsteker import dialogue TILE_SIZE = (64, 64) @@ -12,6 +13,7 @@ # Collision Layers (values are ids not numbers) PC_LAYER = 0 MONSTER_LAYER = 1 +NPC_LAYER = 2 class Monster(Sprite): @@ -40,7 +42,26 @@ class NPC(Sprite): - pass + + image_file = None + collision_layer = NPC_LAYER + collides_with = set([PC_LAYER]) + + debug_color = (240, 240, 240) + + block = True + + 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(midbottom=(pos[0]*TILE_SIZE[0]+TILE_SIZE[0]/2, (pos[1]+1)*TILE_SIZE[1])) + self.collide_rect = self.rect.move(0, 0) + self._layer = Layers.PLAYER + self.setup(**opts) + + def setup(self, dsm, world): + self.dsm = dialogue.DSM(dsm, world) class Projectile(Sprite): @@ -74,7 +95,7 @@ class Geography(Sprite): mobile = False gravitates = False - collides_with = set([PC_LAYER, MONSTER_LAYER]) + collides_with = set([PC_LAYER, MONSTER_LAYER, NPC_LAYER]) is_ground = True bounce_factor = (0.0, 0.0)