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