+ def get_level_data(self):
+ return '\n'.join(reversed([''.join(x) for x in self._data]))
+
+ def _get_wall_tile(self, pos):
+ # Is the neighbour in this direction also a wall?
+ x, y = pos
+ 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 _in_limits(self, pos):
+ if pos[0] < 0:
+ return False
+ if pos[1] < 0:
+ return False
+ try:
+ self._data[pos[1]][pos[0]]
+ except IndexError:
+ return False
+ return True
+