1. Radomir Dopieralski
  2. jelly

Commits

Radomir Dopieralski  committed 66a1869

Pick up items from creates

  • Participants
  • Parent commits 40dbadd
  • Branches default

Comments (0)

Files changed (3)

File jelly/display.py

View file
             sprite = self.mob_sprites[id(mob)]
         except KeyError:
             return
-        msg = message.Message(text, sprite.rect.midbottom)
+        msg = message.Message(text, sprite.rect.center)
         msg.depth = sprite.depth
         self.sprites.add(msg)
 

File jelly/level.py

View file
         if mob.hit(self, attacker):
             self.events.append(('mob_gibs', mob, mob.color, 8, 2))
 
-    def open(self, mob):
+    def open(self, mob, item):
         self.mobs.remove(mob)
         self.events.append(('mob_open', mob))
         self.events.append(('mob_dust', mob, 10, 4))
-        self.message(mob, 'Empty')
+        self.message(mob, item)
+        self.pc.items.append(item)
 
 
     def stand(self, mob, direction, dust=False):

File jelly/mobs.py

View file
     name = 'crate'
     animation = [16]
 
+    def __init__(self, *args, **kwargs):
+        super(Crate, self).__init__(*args, **kwargs)
+        self.item = 'Empty'
+
     def control(self, level):
         pass
 
     def hit(self, level, attacker):
-        level.open(self)
+        level.open(self, self.item)
 
 class Ladder(Mob):
     name = 'ladder'
         self.level = 0
         self.max_hp = 100
         self.hp = self.max_hp
-        self.items = [
-            'Aaaaa',
-            'Bbbbb',
-            'Ccccc',
-            'Ddddd',
-        ]
+        self.items = []
 
 
     def place(self, (x, y)):
         return True
 
     def inventory_menu(self, display):
-        menu = message.Menu((480, 20), self.items)
+        menu = message.Menu((480, 20), self.items or ['Empty'])
         display.render_menu(menu)
         choice = None
         clock = pygame.time.Clock()