3 - Remove old code (direct blit)

This commit is contained in:
kleph 2016-12-07 02:39:09 +01:00
parent 8c0c26e7a8
commit e1ee70f495

View file

@ -86,11 +86,6 @@ class Leaf:
return r return r
def draw(self, ground):
for y in range(0, self.height):
for x in range(0, self.width):
ground.blit((self.x + x)*TILE_SIZE_X, (self.y+y)*TILE_SIZE_Y)
class Room: class Room:
""" room """ """ room """
@ -107,20 +102,6 @@ class Room:
print('[room]' + str(self.id) + ': (' + str(self.x) + '), (' + str(self.y) + ')' + print('[room]' + str(self.id) + ': (' + str(self.x) + '), (' + str(self.y) + ')' +
' - ' + str(self.width) + 'x' + str(self.height)) ' - ' + str(self.width) + 'x' + str(self.height))
def draw(self, wall, ground):
# first wall
for x in range(0, self.width):
wall.blit((self.x+x)*TILE_SIZE_X, self.y*TILE_SIZE_Y)
# middle
for y in range(1, self.height-1):
wall.blit(self.x*TILE_SIZE_X, (self.y+y)*TILE_SIZE_Y)
for x in range(1, self.width - 1):
ground.blit((self.x + x)*TILE_SIZE_X, (self.y+y)*TILE_SIZE_Y)
wall.blit((self.x+self.width-1)*TILE_SIZE_X, (self.y+y)*TILE_SIZE_Y)
# end
for x in range(0, self.width):
wall.blit((self.x+x)*TILE_SIZE_X, (self.y + self.height-1)*TILE_SIZE_Y)
def draw_map(self, tilemap): def draw_map(self, tilemap):
# first wall # first wall
for x in range(0, self.width): for x in range(0, self.width):
@ -170,11 +151,12 @@ 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 # initialize tilemap with road/ground
self.tilemap = [[self.TILE_ROAD for y in range(0, self.sizey)] for x in range(0, self.sizex)] 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
def draw_map(self): def draw_map(self):
@ -182,20 +164,6 @@ class Level:
for x in range(0, self.sizex): for x in range(0, self.sizex):
self.tileset[self.tilemap[x][y]].blit(x*TILE_SIZE_X, y*TILE_SIZE_Y) self.tileset[self.tilemap[x][y]].blit(x*TILE_SIZE_X, y*TILE_SIZE_Y)
def draw_tree(self):
"""
:param t: each leave of t will be draw()
"""
for l in self.tree:
# draw only last leaves
if not l.left_leaf and not l.right_leaf:
l.draw(self.tileset[self.TILE_ROAD])
for l in self.tree:
# draw only last leaves
if not l.left_leaf and not l.right_leaf:
if l.room:
l.room.draw(self.tileset[self.TILE_WALL], self.tileset[self.TILE_GROUND])
def dump_tilemap(self): def dump_tilemap(self):
for y in range(0, self.sizey): for y in range(0, self.sizey):
for x in range(0, self.sizex): for x in range(0, self.sizex):
@ -232,7 +200,6 @@ 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_map() level.draw_map()
label.draw() label.draw()