changeset 332:971c1726c530

don't set position and level when creating a sprite just for the inventory image
author Neil Muller <drnlmuller@gmail.com>
date Sat, 09 Apr 2011 02:16:03 +0200
parents 45755c143813
children e499a10eb41f
files BUGS.txt skaapsteker/sprites/player.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/BUGS.txt	Sat Apr 09 01:48:45 2011 +0200
+++ b/BUGS.txt	Sat Apr 09 02:16:03 2011 +0200
@@ -1,6 +1,6 @@
 * When you bring tea to the monk you don't get rid of the item
-* When you die and respawn on the temple grounds while carrying tea the tea gets dropped by the door but is still in your inventory.  It actually is in your inventory, because you can walk away from the door and really drop it.  The ghost tea disappears if you activate the door.
 
 FIXED
 =====
 * When you re-enter the temple the monk's conversation tree restarts
+* When you die and respawn on the temple grounds while carrying tea the tea gets dropped by the door but is still in your inventory.  It actually is in your inventory, because you can walk away from the door and really drop it.  The ghost tea disappears if you activate the door.
--- a/skaapsteker/sprites/player.py	Sat Apr 09 01:48:45 2011 +0200
+++ b/skaapsteker/sprites/player.py	Sat Apr 09 02:16:03 2011 +0200
@@ -301,13 +301,14 @@
         self.the_world.fox.item = None
 
 
-    def get_sprite(self):
+    def get_sprite(self, set_level):
         my_item = self.the_world.fox.item
         if my_item is None:
             return None
         world_item = getattr(self.the_world.items, my_item)
-        world_item.level = self.the_world.fox.level
-        world_item.pos = [a/b for a, b in zip(self.rect.center, TILE_SIZE)]
+        if set_level:
+            world_item.level = self.the_world.fox.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')
         sprite_dict['name'] = my_item
@@ -316,7 +317,7 @@
 
 
     def drop_item(self):
-        sprite = self.get_sprite()
+        sprite = self.get_sprite(True)
         if sprite is None:
             return
         self.discard_item()
@@ -331,7 +332,7 @@
 
 
     def make_inventory_image(self):
-        sprite = self.get_sprite()
+        sprite = self.get_sprite(False)
         if sprite is None:
             self.inventory_image = None
         image = sprite.image
@@ -342,6 +343,7 @@
             new_height = 48
             new_width = int(image.get_width() * (48.0 / image.get_height()))
         self.inventory_image = pygame.transform.scale(image, (new_width, new_height))
+        sprite.kill() # ensure we don't leak into the scene at any point
 
 
     def take_item_by_name(self, item_name):