changeset 59:8aa795634233

more trash
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Tue, 30 Aug 2011 22:56:55 +0200
parents df1e49cada8c
children 862b8838aaee
files lib/monsters.png lib/things.png src/display.py src/generator.py src/thing.py
diffstat 5 files changed, 52 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
Binary file lib/monsters.png has changed
Binary file lib/things.png has changed
--- a/src/display.py	Sun Aug 28 23:39:03 2011 +0200
+++ b/src/display.py	Tue Aug 30 22:56:55 2011 +0200
@@ -50,17 +50,19 @@
 
 
 class Sprite(pygame.sprite.Sprite):
+    height = 0
+
     def __init__(self, x, y, filename, tx=0, ty=0):
         super(Sprite, self).__init__()
         self.frames = sprites[filename]
         self.image = self.frames[tx][ty]
         self.rect = self.image.get_rect()
-        self.rect.move_ip(x * 24 - 4, y * 16 - 16)
-        self.depth = self.rect.midbottom[1]
+        self.move(x, y)
 
     def move(self, x, y):
         self.rect.topleft = (x * 24 - 4, y * 16 - 16)
-        self.depth = self.rect.midbottom[1]
+        self.depth = self.rect.midbottom[1] + self.height
+
 
 class Overlay(pygame.sprite.Sprite):
     def __init__(self, x, y, image):
--- a/src/generator.py	Sun Aug 28 23:39:03 2011 +0200
+++ b/src/generator.py	Tue Aug 30 22:56:55 2011 +0200
@@ -50,8 +50,13 @@
         return x1, y1
 
     def make_trash(self):
-        trash = [thing.Plant, thing.Chest]
-        for i in range(random.randint(5, 15)):
+        trash = [thing.Plant, thing.Bones, thing.Debris, thing.Rocks,
+                thing.Skull, thing.Bottle, thing.Pot, thing.Shards]
+        for i in range(random.randint(2, 5)):
+            p = self._random_place()
+            if p not in self.things:
+                self.things[p] = thing.Chest(*p)
+        for i in range(random.randint(5, 25)):
             p = self._random_place()
             if p not in self.things:
                 self.things[p] = random.choice(trash)(*p)
--- a/src/thing.py	Sun Aug 28 23:39:03 2011 +0200
+++ b/src/thing.py	Tue Aug 30 22:56:55 2011 +0200
@@ -15,7 +15,8 @@
             self.kill()
             return
         depth = getattr(self.parent, 'depth', None)
-        self.rect.midbottom = (self.parent.rect.midbottom[0], depth)
+        height = getattr(self.parent, 'height', None)
+        self.rect.midbottom = (self.parent.rect.midbottom[0], depth - height)
 
 
 class DoorSprite(display.Sprite):
@@ -115,3 +116,41 @@
 
 class Plant(Thing):
     tx, ty = 2, 2
+
+
+class Bones(Thing):
+    tx, ty = 2, 3
+
+    def __init__(self, x, y):
+        super(Bones, self).__init__(x, y)
+        self.sprite.height = -8;
+        self.sprite.move(x, y)
+
+
+class Skull(Thing):
+    tx, ty = 1, 3
+
+
+class Bottle(Thing):
+    tx, ty = 4, 1
+
+
+class Pot(Thing):
+    tx, ty = 5, 1
+    blocks = True
+
+    def hit(self, damage=0):
+        self.blocks = False
+        self.sprite.image = self.sprite.frames[5][2]
+
+
+class Shards(Thing):
+    tx, ty = 5, 2
+
+
+class Debris(Bones):
+    tx, ty = 4, 0
+
+
+class Rocks(Bones):
+    tx, ty = 5, 0