# HG changeset patch # User Jeremy Thurgood # Date 1302344119 -7200 # Node ID c6552e9fc2e1436aac7056a55ffd15404442b264 # Parent 5c53da24a012772294ed66f33d31e0c6e59c75f8 Added aburage. diff -r 5c53da24a012 -r c6552e9fc2e1 data/game.json --- a/data/game.json Sat Apr 09 12:13:53 2011 +0200 +++ b/data/game.json Sat Apr 09 12:15:19 2011 +0200 @@ -29,7 +29,9 @@ "teapot": { "type": "TeaPot", "level": "temple", "pos": [13, 2], "brewed": false }, "teacupfull": { "type": "TeaCupFull", "level": "_limbo", "pos": [0, 0] }, "vase": { "type": "Vase", "level": "geisha_room", "pos": [1, 3], "broken": false }, - "salmon": { "type": "Salmon", "level": "fishmonger_house", "pos": [1, 3] } + "salmon": { "type": "Salmon", "level": "fishmonger_house", "pos": [1, 3] }, + "aburage_001": { "type": "Aburage", "level": "temple", "pos": [12, 2] }, + "aburage_002": { "type": "Aburage", "level": "temple", "pos": [14, 2] } }, "npcs": { "monk": { "type": "Monk", "level": "temple", "pos": [15, 16], "dsm": "npcs/monk.json", "state": "start" }, diff -r 5c53da24a012 -r c6552e9fc2e1 skaapsteker/sprites/base.py --- a/skaapsteker/sprites/base.py Sat Apr 09 12:13:53 2011 +0200 +++ b/skaapsteker/sprites/base.py Sat Apr 09 12:15:19 2011 +0200 @@ -225,11 +225,11 @@ class Item(GameSprite): mobile = False gravitates = False + actionable = True collision_layer = NPC_LAYER - portable = True - actionable = True + debug_color = (240, 0, 240) def __init__(self, pos, **opts): GameSprite.__init__(self, pos, **opts) @@ -239,13 +239,7 @@ def setup(self, name, world): self.name = name self.world = world - self.item_state = getattr(self.world.items, self.name) - - - def get_debug_color(self): - if self.portable: - return (240, 0, 240) - return (0, 0, 240) + self._me = getattr(self.world.items, self.name) def player_action(self, player): @@ -253,6 +247,10 @@ player.take_item(self) + def remove(self): + self._me.level = '_limbo' + self.kill() + class Geography(Sprite): mobile = False diff -r 5c53da24a012 -r c6552e9fc2e1 skaapsteker/sprites/items.py --- a/skaapsteker/sprites/items.py Sat Apr 09 12:13:53 2011 +0200 +++ b/skaapsteker/sprites/items.py Sat Apr 09 12:15:19 2011 +0200 @@ -1,6 +1,21 @@ from base import Item +################################################## +# Collectibles + +class Aburage(Item): + image_file = 'tofu.png' + + def player_action(self, player): + player.eat_aburage() + self.remove() + + + +################################################## +# Monk tea mission + class TeaCup(Item): image_file = 'teacup_empty.png' @@ -15,7 +30,6 @@ class TeaPot(Item): image_file = 'teapot.png' - portable = False def setup(self, brewed, **opts): super(TeaPot, self).setup(**opts) @@ -23,18 +37,22 @@ def player_action(self, player): if player.has_item('tealeaf'): - self.item_state.brewed = True + self._me.brewed = True player.discard_item() return if player.has_item('teacup'): - if self.item_state.brewed: + if self._me.brewed: player.discard_item() player.take_item_by_name('teacupfull') - self.item_state.brewed = False + self._me.brewed = False else: print "Sadly, the teapot is empty." +################################################## +# Unclassified + + class Vase(Item): image_file = 'dummy.png' @@ -46,3 +64,6 @@ class Salmon(Item): image_file = 'dummy.png' + + + diff -r 5c53da24a012 -r c6552e9fc2e1 skaapsteker/sprites/player.py --- a/skaapsteker/sprites/player.py Sat Apr 09 12:13:53 2011 +0200 +++ b/skaapsteker/sprites/player.py Sat Apr 09 12:15:19 2011 +0200 @@ -39,6 +39,7 @@ self.inventory_image = None # We muck with these in load for convience, so ensure they're right self.the_world = the_world + self._me = the_world.fox self.set_facing('left') self.set_image() self.set_pos((0, 0)) @@ -47,7 +48,7 @@ self._layer = Layers.PLAYER def set_image(self): - key = self._make_key(len(self.the_world.fox.tails)) + key = self._make_key(len(self._me.tails)) images = self._image_dict[key] if self._animation_frame >= len(images): self._animation_frame = 0.0 @@ -167,18 +168,18 @@ self._collisions_seen += 1 if hasattr(other, 'collided_player'): other.collided_player(self) - print 'Health', self.the_world.fox.cur_health + print 'Health', self._me.cur_health def damage(self, damage): - self.the_world.fox.cur_health -= damage + self._me.cur_health -= damage self._soundsystem.play_sound('yelp') - if self.the_world.fox.cur_health <= 0: + if self._me.cur_health <= 0: PlayerDied.post() def restore(self): """Restore player to max health (for restarting levels, etc.)""" - self.the_world.fox.cur_health = self.the_world.fox.max_health + self._me.cur_health = self._me.max_health def set_pos(self, pos): self.rect.midbottom = pos[0] * TILE_SIZE[0] + self.rect_offset[0], (pos[1] + 1) * TILE_SIZE[1] + self.rect_offset[1] @@ -230,13 +231,13 @@ print self._touching_actionables if self._touching_actionables: self._touching_actionables[0].player_action(self) - elif self.the_world.fox.item is not None: + elif self._me.item is not None: self.drop_item() def action_fire1(self): # FIXME: Use the correct tail properties for this - if len(self.the_world.fox.tails) < 2: + if len(self._me.tails) < 2: # Only have a bite attack print 'attacking' self.attacking = 2 @@ -298,16 +299,16 @@ def discard_item(self): - self.the_world.fox.item = None + self._me.item = None def get_sprite(self, set_level): - my_item = self.the_world.fox.item + my_item = self._me.item if my_item is None: return None world_item = getattr(self.the_world.items, my_item) if set_level: - world_item.level = self.the_world.fox.level + world_item.level = self._me.level world_item.pos = [a/b for a, b in zip(self.rect.center, TILE_SIZE)] sprite_dict = world_item.copy() sprite_dict.pop('level') @@ -327,7 +328,7 @@ def take_item(self, item): self.take_item_by_name(item.name) # We create a scaled version of the image for the inventory display - item.kill() + item.remove() print "took", item @@ -349,13 +350,18 @@ def take_item_by_name(self, item_name): self.drop_item() getattr(self.the_world.items, item_name).level = "_limbo" - self.the_world.fox.item = item_name + self._me.item = item_name self.make_inventory_image() def has_item(self, item): - return self.the_world.fox.item == item + return self._me.item == item def add_actionable(self, actionable): self._touching_actionables.append(actionable) + + + def eat_aburage(self): + self._me.tofu += 1 +