Redo the walls
authorNeil <neil@dip.sun.ac.za>
Tue, 16 Apr 2013 22:36:49 +0000 (00:36 +0200)
committerNeil <neil@dip.sun.ac.za>
Tue, 16 Apr 2013 22:36:49 +0000 (00:36 +0200)
42 files changed:
data/sprites/nemesis.png
data/sprites/player.png
data/tiles/bottom_wall.png [new file with mode: 0644]
data/tiles/corner_lb.png [new file with mode: 0644]
data/tiles/corner_lt.png [new file with mode: 0644]
data/tiles/corner_rb.png [new file with mode: 0644]
data/tiles/corner_rt.png [new file with mode: 0644]
data/tiles/cwall.png [new file with mode: 0644]
data/tiles/door.png
data/tiles/end_bottom.png [new file with mode: 0644]
data/tiles/end_left.png [new file with mode: 0644]
data/tiles/end_right.png [new file with mode: 0644]
data/tiles/end_top.png [new file with mode: 0644]
data/tiles/floor.png
data/tiles/horiz_wall.png [new file with mode: 0644]
data/tiles/left_wall.png [new file with mode: 0644]
data/tiles/pillar.png [new file with mode: 0644]
data/tiles/right_wall.png [new file with mode: 0644]
data/tiles/top_wall.png [new file with mode: 0644]
data/tiles/vert_wall.png [new file with mode: 0644]
data/tiles/wall.bmp [deleted file]
erdslangetjie/level.py
sources/bottom_wall.xcf [new file with mode: 0644]
sources/corner_lb.xcf [new file with mode: 0644]
sources/corner_lt.xcf [new file with mode: 0644]
sources/corner_rb.xcf [new file with mode: 0644]
sources/corner_rt.xcf [new file with mode: 0644]
sources/cwall.xcf [new file with mode: 0644]
sources/door.xcf
sources/end_bottom.xcf [new file with mode: 0644]
sources/end_left.xcf [new file with mode: 0644]
sources/end_right.xcf [new file with mode: 0644]
sources/end_top.xcf [new file with mode: 0644]
sources/floor.xcf
sources/horiz_wall.xcf [new file with mode: 0644]
sources/left_wall.xcf [new file with mode: 0644]
sources/nemesis.xcf
sources/pillar.xcf [new file with mode: 0644]
sources/player.xcf
sources/right_wall.xcf [new file with mode: 0644]
sources/top_wall.xcf [new file with mode: 0644]
sources/vert_wall.xcf [new file with mode: 0644]

index 5bd21a5987eabee9d7eb1ff265608298c0a5cdda..ec4812331c0112936d6791dc2df971e85a87ec9b 100644 (file)
Binary files a/data/sprites/nemesis.png and b/data/sprites/nemesis.png differ
index 33080da33ee88f752ede45c6a817074ee94428d7..2d9a49f8a198e02c32a069f3a17b7e1afa510646 100644 (file)
Binary files a/data/sprites/player.png and b/data/sprites/player.png differ
diff --git a/data/tiles/bottom_wall.png b/data/tiles/bottom_wall.png
new file mode 100644 (file)
index 0000000..898fef7
Binary files /dev/null and b/data/tiles/bottom_wall.png differ
diff --git a/data/tiles/corner_lb.png b/data/tiles/corner_lb.png
new file mode 100644 (file)
index 0000000..64f251f
Binary files /dev/null and b/data/tiles/corner_lb.png differ
diff --git a/data/tiles/corner_lt.png b/data/tiles/corner_lt.png
new file mode 100644 (file)
index 0000000..0fd8ce2
Binary files /dev/null and b/data/tiles/corner_lt.png differ
diff --git a/data/tiles/corner_rb.png b/data/tiles/corner_rb.png
new file mode 100644 (file)
index 0000000..0936189
Binary files /dev/null and b/data/tiles/corner_rb.png differ
diff --git a/data/tiles/corner_rt.png b/data/tiles/corner_rt.png
new file mode 100644 (file)
index 0000000..3bcd798
Binary files /dev/null and b/data/tiles/corner_rt.png differ
diff --git a/data/tiles/cwall.png b/data/tiles/cwall.png
new file mode 100644 (file)
index 0000000..849133b
Binary files /dev/null and b/data/tiles/cwall.png differ
index 178d2e97e632025a3cc5ebc0900c84cb8246bbe7..c6885b25ea4416200fe67f1a83f11cde1b71958d 100644 (file)
Binary files a/data/tiles/door.png and b/data/tiles/door.png differ
diff --git a/data/tiles/end_bottom.png b/data/tiles/end_bottom.png
new file mode 100644 (file)
index 0000000..697538a
Binary files /dev/null and b/data/tiles/end_bottom.png differ
diff --git a/data/tiles/end_left.png b/data/tiles/end_left.png
new file mode 100644 (file)
index 0000000..e80a18c
Binary files /dev/null and b/data/tiles/end_left.png differ
diff --git a/data/tiles/end_right.png b/data/tiles/end_right.png
new file mode 100644 (file)
index 0000000..33d9707
Binary files /dev/null and b/data/tiles/end_right.png differ
diff --git a/data/tiles/end_top.png b/data/tiles/end_top.png
new file mode 100644 (file)
index 0000000..daa51bf
Binary files /dev/null and b/data/tiles/end_top.png differ
index 42ccf181c84bd7fe9c975f3f9780637e62bbc115..d7d334db4c60cdc3399ec4eaf94d65357175bf2c 100644 (file)
Binary files a/data/tiles/floor.png and b/data/tiles/floor.png differ
diff --git a/data/tiles/horiz_wall.png b/data/tiles/horiz_wall.png
new file mode 100644 (file)
index 0000000..96bee5b
Binary files /dev/null and b/data/tiles/horiz_wall.png differ
diff --git a/data/tiles/left_wall.png b/data/tiles/left_wall.png
new file mode 100644 (file)
index 0000000..6b56f87
Binary files /dev/null and b/data/tiles/left_wall.png differ
diff --git a/data/tiles/pillar.png b/data/tiles/pillar.png
new file mode 100644 (file)
index 0000000..6b0b4c5
Binary files /dev/null and b/data/tiles/pillar.png differ
diff --git a/data/tiles/right_wall.png b/data/tiles/right_wall.png
new file mode 100644 (file)
index 0000000..29058a8
Binary files /dev/null and b/data/tiles/right_wall.png differ
diff --git a/data/tiles/top_wall.png b/data/tiles/top_wall.png
new file mode 100644 (file)
index 0000000..104ae22
Binary files /dev/null and b/data/tiles/top_wall.png differ
diff --git a/data/tiles/vert_wall.png b/data/tiles/vert_wall.png
new file mode 100644 (file)
index 0000000..5e607be
Binary files /dev/null and b/data/tiles/vert_wall.png differ
diff --git a/data/tiles/wall.bmp b/data/tiles/wall.bmp
deleted file mode 100644 (file)
index 124cb2b..0000000
Binary files a/data/tiles/wall.bmp and /dev/null differ
index d42cc71ea4b92f5eaf748a8633a1627eda3ef762..cbec02c35d899a7ceb18123891bd177b1add1b16 100644 (file)
@@ -3,6 +3,11 @@
 import os
 from data import load_image, load, filepath
 
+WALL = '.'
+FLOOR = ' '
+ENTRY = 'E'
+EXIT = 'X'
+
 
 class Level(object):
 
@@ -25,12 +30,12 @@ class Level(object):
         for j, line in enumerate(self.data):
             tile_line = []
             for i, c in enumerate(line):
-                if c == ' ':
+                if c == FLOOR:
                     tile_line.append(load_image('tiles/floor.png'))
-                elif c == '.':
-                    tile_line.append(load_image('tiles/wall.bmp'))
-                elif c == 'E' or c == 'X':
-                    if c == 'E':
+                elif c == WALL:
+                    tile_line.append(self.get_wall_tile(i, j))
+                elif c == ENTRY or c == EXIT:
+                    if c == ENTRY:
                         if self.enter_pos:
                             raise RuntimeError('Multiple entry points')
                         self.enter_pos = (i, j)
@@ -48,6 +53,58 @@ class Level(object):
     def at_exit(self, pos):
         return pos in self.exit_pos
 
+    def get_wall_tile(self, x, y):
+        # Is the neighbour in this direction also a wall?
+        left = right = top =  bottom = False
+        if x == 0:
+            left = True
+        elif self.data[y][x - 1] == WALL:
+            left = True
+        if x == len(self.data[0]) - 1:
+            right = True
+        elif self.data[y][x + 1] == WALL:
+            right = True
+        if y == 0:
+            top = True
+        elif self.data[y - 1][x] == WALL:
+            top = True
+        if y == len(self.data) - 1:
+            bottom = True
+        elif self.data[y + 1][x] == WALL:
+            bottom = True
+        if top and bottom and left and right:
+            return load_image('tiles/cwall.png')
+        elif bottom and left and right:
+            return load_image('tiles/bottom_wall.png')
+        elif top and left and right:
+            return load_image('tiles/top_wall.png')
+        elif top and bottom and right:
+            return load_image('tiles/left_wall.png')
+        elif top and bottom and left:
+            return load_image('tiles/right_wall.png')
+        elif top and bottom:
+            return load_image('tiles/vert_wall.png')
+        elif left and right:
+            return load_image('tiles/horiz_wall.png')
+        elif left and top:
+            return load_image('tiles/corner_lt.png')
+        elif left and bottom:
+            return load_image('tiles/corner_lb.png')
+        elif right and top:
+            return load_image('tiles/corner_rt.png')
+        elif right and bottom:
+            return load_image('tiles/corner_rb.png')
+        elif top:
+            return load_image('tiles/end_top.png')
+        elif bottom:
+            return load_image('tiles/end_bottom.png')
+        elif left:
+            return load_image('tiles/end_right.png')
+        elif right:
+            return load_image('tiles/end_left.png')
+        return load_image('tiles/pillar.png')
+
+
     def blocked(self, pos):
         if pos[0] < 0:
             return True
diff --git a/sources/bottom_wall.xcf b/sources/bottom_wall.xcf
new file mode 100644 (file)
index 0000000..8522d5d
Binary files /dev/null and b/sources/bottom_wall.xcf differ
diff --git a/sources/corner_lb.xcf b/sources/corner_lb.xcf
new file mode 100644 (file)
index 0000000..9442bf2
Binary files /dev/null and b/sources/corner_lb.xcf differ
diff --git a/sources/corner_lt.xcf b/sources/corner_lt.xcf
new file mode 100644 (file)
index 0000000..94105ca
Binary files /dev/null and b/sources/corner_lt.xcf differ
diff --git a/sources/corner_rb.xcf b/sources/corner_rb.xcf
new file mode 100644 (file)
index 0000000..5750589
Binary files /dev/null and b/sources/corner_rb.xcf differ
diff --git a/sources/corner_rt.xcf b/sources/corner_rt.xcf
new file mode 100644 (file)
index 0000000..71ee580
Binary files /dev/null and b/sources/corner_rt.xcf differ
diff --git a/sources/cwall.xcf b/sources/cwall.xcf
new file mode 100644 (file)
index 0000000..0d83fbd
Binary files /dev/null and b/sources/cwall.xcf differ
index 34b182d9458f87b3834fbbf22d1e9104f3620c5e..b80964e748204a593e86f5a6fe4298bdd1dfa72d 100644 (file)
Binary files a/sources/door.xcf and b/sources/door.xcf differ
diff --git a/sources/end_bottom.xcf b/sources/end_bottom.xcf
new file mode 100644 (file)
index 0000000..eb8f806
Binary files /dev/null and b/sources/end_bottom.xcf differ
diff --git a/sources/end_left.xcf b/sources/end_left.xcf
new file mode 100644 (file)
index 0000000..7e44865
Binary files /dev/null and b/sources/end_left.xcf differ
diff --git a/sources/end_right.xcf b/sources/end_right.xcf
new file mode 100644 (file)
index 0000000..6604c70
Binary files /dev/null and b/sources/end_right.xcf differ
diff --git a/sources/end_top.xcf b/sources/end_top.xcf
new file mode 100644 (file)
index 0000000..593462e
Binary files /dev/null and b/sources/end_top.xcf differ
index d8efcc09752a7c27be158be703108242467ed6e7..4d912459092f23836b68296a4778dcf4374a89bc 100644 (file)
Binary files a/sources/floor.xcf and b/sources/floor.xcf differ
diff --git a/sources/horiz_wall.xcf b/sources/horiz_wall.xcf
new file mode 100644 (file)
index 0000000..dd482cc
Binary files /dev/null and b/sources/horiz_wall.xcf differ
diff --git a/sources/left_wall.xcf b/sources/left_wall.xcf
new file mode 100644 (file)
index 0000000..7b9aace
Binary files /dev/null and b/sources/left_wall.xcf differ
index 16152c0206cbf5e8238c3eec9030c7d3a6d3e178..478225177605c7783bffb30181f3740c5e0b0ddc 100644 (file)
Binary files a/sources/nemesis.xcf and b/sources/nemesis.xcf differ
diff --git a/sources/pillar.xcf b/sources/pillar.xcf
new file mode 100644 (file)
index 0000000..39d7ab3
Binary files /dev/null and b/sources/pillar.xcf differ
index 224e67ba07e75148b40af790b09a43abecc98c25..9cc6da244a3f1bfa969401725babb64d0dd1e44d 100644 (file)
Binary files a/sources/player.xcf and b/sources/player.xcf differ
diff --git a/sources/right_wall.xcf b/sources/right_wall.xcf
new file mode 100644 (file)
index 0000000..2beebef
Binary files /dev/null and b/sources/right_wall.xcf differ
diff --git a/sources/top_wall.xcf b/sources/top_wall.xcf
new file mode 100644 (file)
index 0000000..66ca911
Binary files /dev/null and b/sources/top_wall.xcf differ
diff --git a/sources/vert_wall.xcf b/sources/vert_wall.xcf
new file mode 100644 (file)
index 0000000..9e759f7
Binary files /dev/null and b/sources/vert_wall.xcf differ