Nov-09-2017, 01:53 AM
I am a beginner to programming but have been interested in mazes, and I was trying to run this program :
http://thelinuxchronicles.blogspot.in/20...ution.html
But, the output comes all at once, and I want to slow it down so that one can actually see the red line painting the path slowly.
I've tried adding a sleep() delay in the elif and if cases, and i expected it to slow it down, but it just slows down the appearance of the line(it still appears all at once). Where do I have to put it?Thank you.
56 # paints the solution path in the maze window 57 def maze_path_window(m,w): 58 path = m.solutionpath 59 60 # print every cell within the solution path 61 for index in range(len(path)-1): 62 actrow = path[index][0] 63 actcol = path[index][1] 64 nextrow = path[index+1][0] 65 nextcol = path[index+1][1] 66 pygame.draw.rect(w,RED,(actcol*CELLSIZE+(actcol+1)*WALLSIZE,actrow*CELLSIZE+(actrow+ 67 1)*WALLSIZE,CELLSIZE,CELLSIZE)) 68 69 # also paint the white spaces between the cells 70 if actrow == nextrow: 71 if actcol < nextcol: 72 pygame.draw.rect(w,RED,((actcol+1)*CELLSIZE+(actcol+1)*WALLSIZE,actrow*CELLSIZE+ 73 (actrow+1)*WALLSIZE,WALLSIZE,CELLSIZE)) 74 else: 75 pygame.draw.rect(w,RED,(actcol*CELLSIZE+actcol*WALLSIZE,actrow*CELLSIZE+(actrow+ 76 1)*WALLSIZE,WALLSIZE,CELLSIZE)) 77 elif actcol == nextcol: 78 if actrow < nextrow: 79 pygame.draw.rect(w,RED,(actcol*CELLSIZE+(actcol+1)*WALLSIZE,(actrow+1)*CELLSIZE+ 80 (actrow+1)*WALLSIZE,CELLSIZE,WALLSIZE)) 81 else: 82 pygame.draw.rect(w,RED,(actcol*CELLSIZE+(actcol+1)*WALLSIZE,actrow*CELLSIZE+ 83 actrow*WALLSIZE,CELLSIZE,WALLSIZE))