def recursive(current: Square): self.clock.tick(f['maze_generation_fps']) current.color = colors['maze'] pygame.display.flip() for event in pygame.event.get(): if event.type == pygame.QUIT or event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE: pygame.quit() exit() used.append(current) for square in current.neighbours(self, maze=True): if square in used: continue wall_x = (square.x + current.x) // 2 wall_y = (square.y + current.y) // 2 w_sq = self.nodes[wall_x, wall_y] self.walls.remove(w_sq) w_sq.color = colors['maze'] recursive(square) w_sq.color = colors[1] current.color = colors[1] return