diff --git a/03_map.py b/03_map.py index 481ba64..2ce1993 100644 --- a/03_map.py +++ b/03_map.py @@ -32,7 +32,7 @@ class Leaf: def is_terminal(self): """ Returns True if the leave has no children """ - if self.left_leave or self.right_leave: + if self.left_leaf or self.right_leaf: return False return True @@ -136,7 +136,6 @@ class Room: tilemap[self.x + x][self.y + self.height - 1] = Level.TILE_WALL - class Level: TILE_WALL = 0 TILE_ROAD = 1 @@ -148,7 +147,7 @@ class Level: self.tilemap = [[self.TILE_ROAD for y in range(0, sizey)] for x in range(0, sizex)] if tile_file: self.load_tileset(tile_file) - self.generate_tree() + self.tree = self.generate_tree() def load_tileset(self, tile_file): resource_file = open(tile_file) @@ -162,17 +161,18 @@ class Level: def generate_tree(self): # init tree - self.tree = [Leaf(0, 0, 30, 30, 0)] + tree = [Leaf(0, 0, 30, 30, 0)] # split leaves until none succeed # Lists are ordered. Tree will be created and travel from left to right - for l in self.tree: + for l in tree: if l.split(): - self.tree.append(l.left_leaf) - self.tree.append(l.right_leaf) + tree.append(l.left_leaf) + tree.append(l.right_leaf) # create rooms from partitions - self.tree[0].generate_rooms(self.tilemap) + tree[0].generate_rooms(self.tilemap) + return tree def draw_map(self): for y in range(0, self.sizey): @@ -230,7 +230,6 @@ def on_key_press(symbol, modifiers): def on_draw(): window.clear() level.draw_tree() - label.draw()