Mercurial > skaapsteker
diff skaapsteker/sprites/player.py @ 335:c6552e9fc2e1
Added aburage.
author | Jeremy Thurgood <firxen@gmail.com> |
---|---|
date | Sat, 09 Apr 2011 12:15:19 +0200 |
parents | 971c1726c530 |
children | c8fd82ff0c71 |
line wrap: on
line diff
--- 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 +