PEP-8
This commit is contained in:
parent
c64e376da4
commit
b074d2de01
1 changed files with 14 additions and 9 deletions
|
@ -12,6 +12,7 @@ TILE_SIZE_Y = 16
|
|||
|
||||
MIN_LEAF_SIZE = 7
|
||||
|
||||
|
||||
class Leaf:
|
||||
""" Leaf of the BSP """
|
||||
|
||||
|
@ -79,6 +80,7 @@ class Leaf:
|
|||
for x in range(0, self.width):
|
||||
ground.blit((self.x + x)*TILE_SIZE_X, (self.y+y)*TILE_SIZE_Y)
|
||||
|
||||
|
||||
class Room:
|
||||
""" room """
|
||||
|
||||
|
@ -108,6 +110,7 @@ class Room:
|
|||
for x in range(0, self.width):
|
||||
wall.blit((self.x+x)*TILE_SIZE_X, (self.y + self.height-1)*TILE_SIZE_Y)
|
||||
|
||||
|
||||
def generate_tree():
|
||||
# init tree
|
||||
tree = [Leaf(0, 0, 30, 30, 0)]
|
||||
|
@ -119,8 +122,8 @@ def generate_tree():
|
|||
while split_done:
|
||||
split_done = False
|
||||
for l in tree:
|
||||
if l.left_leaf == None and l.right_leaf == None:
|
||||
if (l.split()):
|
||||
if l.left_leaf and l.right_leaf:
|
||||
if l.split():
|
||||
tree.append(l.left_leaf)
|
||||
tree.append(l.right_leaf)
|
||||
split_done = True
|
||||
|
@ -138,6 +141,7 @@ def generate_tree():
|
|||
# main window
|
||||
window = pyglet.window.Window()
|
||||
|
||||
|
||||
@window.event
|
||||
def on_key_press(symbol, modifiers):
|
||||
# TODO: ugly hack
|
||||
|
@ -154,6 +158,7 @@ def on_key_press(symbol, modifiers):
|
|||
elif symbol == key.ENTER:
|
||||
print('Enter !')
|
||||
|
||||
|
||||
@window.event
|
||||
def on_draw():
|
||||
window.clear()
|
||||
|
@ -167,11 +172,11 @@ def draw_tree(t):
|
|||
"""
|
||||
for l in t:
|
||||
# draw only last leaves
|
||||
if l.left_leaf == None and l.right_leaf == None:
|
||||
if l.left_leaf and l.right_leaf:
|
||||
l.draw(tiles[TILE_ROAD])
|
||||
for l in t:
|
||||
# draw only last leaves
|
||||
if l.left_leaf == None and l.right_leaf == None:
|
||||
if l.left_leaf and l.right_leaf:
|
||||
if l.room:
|
||||
l.room.draw(tiles[TILE_WALL], tiles[TILE_GROUND])
|
||||
|
||||
|
|
Loading…
Reference in a new issue