3 - Remove old code (direct blit)
This commit is contained in:
parent
8c0c26e7a8
commit
e1ee70f495
1 changed files with 2 additions and 35 deletions
35
03_map.py
35
03_map.py
|
@ -86,11 +86,6 @@ class Leaf:
|
|||
|
||||
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:
|
||||
""" room """
|
||||
|
@ -107,20 +102,6 @@ class Room:
|
|||
print('[room]' + str(self.id) + ': (' + str(self.x) + '), (' + str(self.y) + ')' +
|
||||
' - ' + 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):
|
||||
# first wall
|
||||
for x in range(0, self.width):
|
||||
|
@ -175,6 +156,7 @@ class Level:
|
|||
|
||||
# create rooms from partitions
|
||||
tree[0].generate_rooms(self.tilemap)
|
||||
|
||||
return tree
|
||||
|
||||
def draw_map(self):
|
||||
|
@ -182,20 +164,6 @@ class Level:
|
|||
for x in range(0, self.sizex):
|
||||
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):
|
||||
for y in range(0, self.sizey):
|
||||
for x in range(0, self.sizex):
|
||||
|
@ -232,7 +200,6 @@ def on_key_press(symbol, modifiers):
|
|||
@window.event
|
||||
def on_draw():
|
||||
window.clear()
|
||||
#level.draw_tree()
|
||||
level.draw_map()
|
||||
label.draw()
|
||||
|
||||
|
|
Loading…
Reference in a new issue