From: Neil Date: Tue, 16 Apr 2013 22:36:49 +0000 (+0200) Subject: Redo the walls X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=64e0ef0f5aaa615ba6821a9924206b4d373e2a21;p=erdslangetjie.git Redo the walls --- diff --git a/data/sprites/nemesis.png b/data/sprites/nemesis.png index 5bd21a5..ec48123 100644 Binary files a/data/sprites/nemesis.png and b/data/sprites/nemesis.png differ diff --git a/data/sprites/player.png b/data/sprites/player.png index 33080da..2d9a49f 100644 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 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 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 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 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 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 index 0000000..849133b Binary files /dev/null and b/data/tiles/cwall.png differ diff --git a/data/tiles/door.png b/data/tiles/door.png index 178d2e9..c6885b2 100644 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 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 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 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 index 0000000..daa51bf Binary files /dev/null and b/data/tiles/end_top.png differ diff --git a/data/tiles/floor.png b/data/tiles/floor.png index 42ccf18..d7d334d 100644 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 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 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 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 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 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 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 index 124cb2b..0000000 Binary files a/data/tiles/wall.bmp and /dev/null differ diff --git a/erdslangetjie/level.py b/erdslangetjie/level.py index d42cc71..cbec02c 100644 --- a/erdslangetjie/level.py +++ b/erdslangetjie/level.py @@ -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 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 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 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 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 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 index 0000000..0d83fbd Binary files /dev/null and b/sources/cwall.xcf differ diff --git a/sources/door.xcf b/sources/door.xcf index 34b182d..b80964e 100644 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 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 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 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 index 0000000..593462e Binary files /dev/null and b/sources/end_top.xcf differ diff --git a/sources/floor.xcf b/sources/floor.xcf index d8efcc0..4d91245 100644 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 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 index 0000000..7b9aace Binary files /dev/null and b/sources/left_wall.xcf differ diff --git a/sources/nemesis.xcf b/sources/nemesis.xcf index 16152c0..4782251 100644 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 index 0000000..39d7ab3 Binary files /dev/null and b/sources/pillar.xcf differ diff --git a/sources/player.xcf b/sources/player.xcf index 224e67b..9cc6da2 100644 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 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 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 index 0000000..9e759f7 Binary files /dev/null and b/sources/vert_wall.xcf differ