# HG changeset patch # User Neil Muller # Date 1302378799 -7200 # Node ID 18427edff33a3a500644500fcadb730f13c88acb # Parent 9e85c30dd12fec8b4065209b10b890d64f4efeb5 Add facing support to npcs diff -r 9e85c30dd12f -r 18427edff33a data/game.json --- a/data/game.json Sat Apr 09 21:35:28 2011 +0200 +++ b/data/game.json Sat Apr 09 21:53:19 2011 +0200 @@ -156,19 +156,19 @@ "aburage_99": { "type": "Aburage", "level": "celestial_plane", "pos": [1, 1] } }, "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", "block": true }, - "hattori": { "type": "Hattori", "level": "road", "pos": [37, 8], "dsm": "npcs/hattori.json", "state": "start", "block": true }, - "ichiro": { "type": "Ichiro", "level": "road", "pos": [36, 8], "dsm": "npcs/ichiro.json", "state": "start", "block": true }, - "sasuke": { "type": "Sasuke", "level": "road", "pos": [56, 8], "dsm": "npcs/sasuke.json", "state": "start", "block": true }, - "kaneda2": { "type": "Kaneda", "level": "tea_house", "pos": [6, 10], "dsm": "npcs/kaneda2.json", "state": "start" }, - "tetsuo": { "type": "Tetsuo", "level": "tea_house", "pos": [9, 10], "dsm": "npcs/tetsuo.json", "state": "start" }, - "kaneda": { "type": "Kaneda", "level": "geisha_house", "pos": [10, 3], "dsm": "npcs/kaneda.json", "state": "start" }, - "kumiko": { "type": "Kumiko", "level": "geisha_room", "pos": [11, 13], "dsm": "npcs/kumiko.json", "state": "start" }, - "maneki": { "type": "Maneki", "level": "market", "pos": [35, 6], "dsm": "npcs/maneki.json", "state": "start" }, - "fishmonger": { "type": "FishMonger", "level": "fishmonger_house", "pos": [23, 5], "dsm": "npcs/fishmonger.json", "state": "start" }, - "actor": { "type": "Actor", "level": "theatre", "pos": [12, 9], "dsm": "npcs/actor.json", "state": "start" }, - "kitsune": { "type": "Kitsune", "level": "celestial_plane", "pos": [17, 20], "dsm": "npcs/kitsune.json", "state": "start" } + "monk": { "type": "Monk", "level": "temple", "pos": [15, 16], "dsm": "npcs/monk.json", "state": "start", "facing": null }, + "guard": { "type": "Guard", "level": "temple_grounds", "pos": [5, 11], "dsm": "npcs/guard.json", "state": "start", "facing": null, "block": true }, + "hattori": { "type": "Hattori", "level": "road", "pos": [37, 8], "dsm": "npcs/hattori.json", "state": "start", "facing": "left", "block": true }, + "ichiro": { "type": "Ichiro", "level": "road", "pos": [36, 8], "dsm": "npcs/ichiro.json", "state": "start", "facing": "right", "block": true }, + "sasuke": { "type": "Sasuke", "level": "road", "pos": [56, 8], "dsm": "npcs/sasuke.json", "state": "start", "facing": null, "block": true }, + "kaneda2": { "type": "Kaneda", "level": "tea_house", "pos": [6, 10], "dsm": "npcs/kaneda2.json", "state": "start", "facing": null }, + "tetsuo": { "type": "Tetsuo", "level": "tea_house", "pos": [9, 10], "dsm": "npcs/tetsuo.json", "state": "start" , "facing": null}, + "kaneda": { "type": "Kaneda", "level": "geisha_house", "pos": [10, 3], "dsm": "npcs/kaneda.json", "state": "start" , "facing": null}, + "kumiko": { "type": "Kumiko", "level": "geisha_room", "pos": [11, 13], "dsm": "npcs/kumiko.json", "state": "start" , "facing": null}, + "maneki": { "type": "Maneki", "level": "market", "pos": [35, 6], "dsm": "npcs/maneki.json", "state": "start" , "facing": null}, + "fishmonger": { "type": "FishMonger", "level": "fishmonger_house", "pos": [23, 5], "dsm": "npcs/fishmonger.json", "state": "start" , "facing": null}, + "actor": { "type": "Actor", "level": "theatre", "pos": [12, 9], "dsm": "npcs/actor.json", "state": "start" , "facing": null}, + "kitsune": { "type": "Kitsune", "level": "celestial_plane", "pos": [17, 20], "dsm": "npcs/kitsune.json", "state": "start" , "facing": null} }, "levels": { "celestial_plane" : "celestial_plane", diff -r 9e85c30dd12f -r 18427edff33a skaapsteker/sprites/base.py --- a/skaapsteker/sprites/base.py Sat Apr 09 21:35:28 2011 +0200 +++ b/skaapsteker/sprites/base.py Sat Apr 09 21:53:19 2011 +0200 @@ -273,10 +273,11 @@ AnimatedGameSprite.__init__(self, pos, **opts) self._layer = Layers.PLAYER - def setup(self, name, world, dsm, state): + def setup(self, name, world, dsm, state, facing): self.name = name self.dsm = dialogue.DSM(name, world, dsm, state) self._me = getattr(world.npcs, self.name) + self.facing = facing def player_action(self, player): OpenDialog.post(self) @@ -288,8 +289,8 @@ mobile = False block = True - def setup(self, name, world, dsm, state, block): - NPC.setup(self, name, world, dsm, state) + def setup(self, name, world, dsm, state, facing, block): + NPC.setup(self, name, world, dsm, state, facing) self.block = block self._animation = 'standing' diff -r 9e85c30dd12f -r 18427edff33a skaapsteker/sprites/npcs.py --- a/skaapsteker/sprites/npcs.py Sat Apr 09 21:35:28 2011 +0200 +++ b/skaapsteker/sprites/npcs.py Sat Apr 09 21:53:19 2011 +0200 @@ -1,4 +1,5 @@ from .base import NPC, BlockingNPC +from pygame import transform class Monk(NPC): @@ -20,10 +21,24 @@ class Hattori(BlockingNPC): image_dir = 'sprites/hattori' + facings = { + 'running' : (('left', None), + ('right', lambda x: transform.flip(x, True, False))), + 'standing' : (('left', None), + ('right', lambda x: transform.flip(x, True, False))), + } + class Ichiro(BlockingNPC): image_dir = 'sprites/ichiro' + facings = { + 'running' : (('left', None), + ('right', lambda x: transform.flip(x, True, False))), + 'standing' : (('left', None), + ('right', lambda x: transform.flip(x, True, False))), + } + class Kaneda(NPC):