Fininsh tidying
This commit is contained in:
17
drawing.py
17
drawing.py
@@ -5,7 +5,8 @@ from consts import *
|
||||
|
||||
|
||||
def draw_cell(display, position, color):
|
||||
position = (position[0] * CELL_SIZE + PADDING, position[1] * CELL_SIZE + PADDING)
|
||||
position = (position[0] * CELL_SIZE + PADDING,
|
||||
position[1] * CELL_SIZE + PADDING)
|
||||
rect = pygame.Rect(position, (40, 40))
|
||||
pygame.draw.rect(display, color, rect)
|
||||
|
||||
@@ -26,3 +27,17 @@ def draw_path(display, color, path):
|
||||
n1 = center_line(gridtoscreen(path[i].g_pos()))
|
||||
n2 = center_line(gridtoscreen(path[i + 1].g_pos()))
|
||||
pygame.draw.line(display, color, n1, n2, 4)
|
||||
|
||||
|
||||
def draw_grid(display, grid):
|
||||
for row in range(0, ROWS):
|
||||
for column in range(0, COLS):
|
||||
node = grid[row][column]
|
||||
if node.celltype == 0:
|
||||
draw_cell(display, (row, column), CELL_COLOR)
|
||||
elif node.celltype == 1:
|
||||
draw_cell(display, (row, column), WALL_COLOR)
|
||||
elif node.celltype == 2:
|
||||
draw_cell(display, (row, column), START_COLOR)
|
||||
elif node.celltype == 3:
|
||||
draw_cell(display, (row, column), END_COLOR)
|
||||
|
||||
Reference in New Issue
Block a user