changeset 54:83a5c8c1e1a6

added a Plant monster
author Radomir Dopieralski <sheep-devel@sheep.art.pl>
date Sun, 28 Aug 2011 22:42:21 +0200
parents 11633a298288
children d278a39dc4d6
files lib/monsters.png src/display.py src/generator.py src/level.py src/monster.py
diffstat 5 files changed, 23 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
Binary file lib/monsters.png has changed
--- a/src/display.py	Sun Aug 28 19:40:37 2011 +0200
+++ b/src/display.py	Sun Aug 28 22:42:21 2011 +0200
@@ -81,14 +81,11 @@
         self.alpha = 255
         shade = sprites['things.png'][0][3]
         for x, y in dark:
-#            self.image.fill((255, 255, 255), rect=pygame.rect.Rect(
-#                        x * 24, y * 16, 24, 16))
                 self.image.blit(shade, (x*24, y*16), (0, 0, 32, 32),
                             pygame.BLEND_RGB_SUB)
 
-
     def update(self):
-        self.alpha -= 32
+        self.alpha -= 24
         if self.alpha < 0:
             self.kill()
             return
--- a/src/generator.py	Sun Aug 28 19:40:37 2011 +0200
+++ b/src/generator.py	Sun Aug 28 22:42:21 2011 +0200
@@ -10,7 +10,7 @@
     depth_monsters = [
         [monster.Bat],
         [monster.Bat, monster.Skeleton],
-        [monster.Bat, monster.Skeleton, monster.Zombie],
+        [monster.Bat, monster.Skeleton, monster.Plant],
         [monster.Skeleton, monster.Zombie],
         [monster.Skeleton, monster.Zombie, monster.Jelly],
         [monster.Skeleton, monster.Zombie, monster.Jelly, monster.Ghost],
@@ -21,7 +21,7 @@
         [monster.Jack, monster.Eye],
         [monster.Bat, monster.Jack, monster.Eye],
         [monster.Bat, monster.Skeleton, monster.Zombie, monster.Jack,
-         monster.Eye, monster.Jelly, monster.Ghost],
+         monster.Eye, monster.Jelly, monster.Ghost, monster.Plant],
     ]
 
     def __init__(self, depth):
--- a/src/level.py	Sun Aug 28 19:40:37 2011 +0200
+++ b/src/level.py	Sun Aug 28 22:42:21 2011 +0200
@@ -143,20 +143,20 @@
             m.render(display)
         self.render_map(display, None)
 
-    def get_room(self, x, y):
+    def get_rooms(self, x, y):
         for line in self.rooms:
             for room in line:
                 if room[0] <= x <= room[2] and room[1] <= y <= room[3]:
-                    return room
-        raise KeyError('Not in any room')
+                    yield room
 
     def explore(self, to_display, x, y):
-        try:
-            room = self.get_room(x, y)
+        for room in self.get_rooms(x, y):
             area = (room[0] + 1, room[1] + 1, room[2], room[3])
-        except KeyError:
-            room = None
-            area = (x, y, x + 1, y + 1)
+            self.light_area(to_display, area)
+        area = (x, y, x + 1, y + 1)
+        self.light_area(to_display, area)
+
+    def light_area(self, to_display, area):
         area = (max(0, area[0] - 1), max(0, area[1] - 1),
                 min(len(self.map[0]), area[2] + 1),
                 min(len(self.map), area[3] + 1))
--- a/src/monster.py	Sun Aug 28 19:40:37 2011 +0200
+++ b/src/monster.py	Sun Aug 28 22:42:21 2011 +0200
@@ -231,3 +231,15 @@
     name = "jelly"
     max_hp = 6
     alpha = 192
+
+
+class Plant(Monster):
+    tx = 7
+    name = "plant"
+    max_hp = 4
+
+    def act(self, level):
+        # Never move, only attack
+        if distance(level.hero.x, level.hero.y, self.x, self.y) == 1:
+            self.attack(level, level.hero.x - self.x, level.hero.y - self.y)
+            return