Fininsh tidying

This commit is contained in:
__
2024-04-29 01:19:47 +02:00
parent 614e5393e3
commit 40e719aa11
4 changed files with 62 additions and 34 deletions

View File

@@ -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)