def gen_maze_helper(self, x, y):
if x + 1 > c.COLS or y + 1 > c.ROWS or x < 0 or y < 0 or self.maze[x][y].visited:
return False
else:
self.maze[x][y].visited = True
self.draw_maze(c.SCREEN, c.COLS, c.ROWS, False)
pygame.display.flip() // i assume it is so slow because update gets called so much
if (
self.gen_maze_helper(x + 1, y)
or self.gen_maze_helper(x - 1, y)
or self.gen_maze_helper(x, y + 1)
or self.gen_maze_helper(x, y - 1)
):
print("test")
def draw_maze(self, screen, cols, rows, done):
for i in range(cols):
for j in range(rows):
self.maze[i][j].draw(screen)
if not done:
pygame.time.delay(25)
pygame.display.update()
# this is for the original "animation" - it can be done every cell but gets too slow if there are 100+ cells
The logic is a mess and in progress so please dont focus on that – the main issue is the the slow update or the drawing. I had to once row at a time instead of one cell at a time because it was too slow
New contributor
Jace – is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.