03 - Really draw the map and initialize it at each new generation

This commit is contained in:
kleph 2016-12-07 01:38:58 +01:00
parent 5e06fdb3df
commit 8c0c26e7a8

View file

@ -144,7 +144,7 @@ class Level:
def __init__(self, sizex, sizey, tile_file=None): def __init__(self, sizex, sizey, tile_file=None):
self.sizex, self.sizey = sizex, sizey self.sizex, self.sizey = sizex, sizey
self.tileset = [] self.tileset = []
self.tilemap = [[self.TILE_ROAD for y in range(0, sizey)] for x in range(0, sizex)] self.tilemap = []
if tile_file: if tile_file:
self.load_tileset(tile_file) self.load_tileset(tile_file)
self.tree = self.generate_tree() self.tree = self.generate_tree()
@ -170,6 +170,9 @@ class Level:
tree.append(l.left_leaf) tree.append(l.left_leaf)
tree.append(l.right_leaf) tree.append(l.right_leaf)
#initialize tilemap with road/ground
self.tilemap = [[self.TILE_ROAD for y in range(0, self.sizey)] for x in range(0, self.sizex)]
# create rooms from partitions # create rooms from partitions
tree[0].generate_rooms(self.tilemap) tree[0].generate_rooms(self.tilemap)
return tree return tree
@ -229,7 +232,8 @@ def on_key_press(symbol, modifiers):
@window.event @window.event
def on_draw(): def on_draw():
window.clear() window.clear()
level.draw_tree() #level.draw_tree()
level.draw_map()
label.draw() label.draw()