# HG changeset patch # User Neil Muller # Date 1302372598 -7200 # Node ID 8b9b4706a4d6ff0ba9ec5149da4589b93a1e3ad8 # Parent 6e065efdcec61fea59bdbcd3f8ea1079366405f6 Blocking NPC's block diff -r 6e065efdcec6 -r 8b9b4706a4d6 data/game.json --- a/data/game.json Sat Apr 09 20:50:01 2011 +0200 +++ b/data/game.json Sat Apr 09 20:09:58 2011 +0200 @@ -157,7 +157,7 @@ }, "npcs": { "monk": { "type": "Monk", "level": "temple", "pos": [15, 16], "dsm": "npcs/monk.json", "state": "start" }, - "guard": { "type": "Guard", "level": "temple_grounds", "pos": [5, 11], "dsm": "npcs/guard.json", "state": "start" }, + "guard": { "type": "Guard", "level": "temple_grounds", "pos": [5, 11], "dsm": "npcs/guard.json", "state": "start", "block": true }, "hattori": { "type": "Hattori", "level": "road", "pos": [36, 8], "dsm": "npcs/hattori.json", "state": "start" }, "ichiro": { "type": "Ichiro", "level": "road", "pos": [37, 8], "dsm": "npcs/ichiro.json", "state": "start" }, "sasuke": { "type": "Sasuke", "level": "road", "pos": [56, 8], "dsm": "npcs/sasuke.json", "state": "start" }, diff -r 6e065efdcec6 -r 8b9b4706a4d6 skaapsteker/physics.py --- a/skaapsteker/physics.py Sat Apr 09 20:50:01 2011 +0200 +++ b/skaapsteker/physics.py Sat Apr 09 20:09:58 2011 +0200 @@ -313,8 +313,10 @@ # Action stuff. # Happens after updates, because we only want it for the next frame. for sprite in self._actors: + actor_collide_rect = sprite.collide_rect.inflate((4, 4)) for other in self._actionables: - if sprite.collide_rect.colliderect(other.collide_rect): + other_actor_collide_rect = other.collide_rect.inflate((4, 4)) + if actor_collide_rect.colliderect(other_actor_collide_rect): sprite.add_actionable(other) diff -r 6e065efdcec6 -r 8b9b4706a4d6 skaapsteker/sprites/base.py --- a/skaapsteker/sprites/base.py Sat Apr 09 20:50:01 2011 +0200 +++ b/skaapsteker/sprites/base.py Sat Apr 09 20:09:58 2011 +0200 @@ -281,6 +281,18 @@ OpenDialog.post(self) +class BlockingNPC(NPC): + + collides_with = set([PC_LAYER]) + mobile = False + block = True + + def setup(self, name, world, dsm, state, block): + NPC.setup(self, name, world, dsm, state) + self.block = block + self._animation = 'standing' + + class Projectile(AnimatedGameSprite): collision_layer = PROJECTILE_LAYER diff -r 6e065efdcec6 -r 8b9b4706a4d6 skaapsteker/sprites/npcs.py --- a/skaapsteker/sprites/npcs.py Sat Apr 09 20:50:01 2011 +0200 +++ b/skaapsteker/sprites/npcs.py Sat Apr 09 20:09:58 2011 +0200 @@ -1,4 +1,4 @@ -from .base import NPC +from .base import NPC, BlockingNPC class Monk(NPC): @@ -8,10 +8,11 @@ ] -class Guard(NPC): +class Guard(BlockingNPC): image_dir = 'sprites/guard' + class Hattori(NPC): image_dir = 'sprites/hattori'