Skip to content

Commit 533856f

Browse files
committed
Flickering issue of Rat in the Maze Resolved
1 parent 35b21f3 commit 533856f

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

Rat_In_The_Maze.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import time
33
from threading import *
44
import ExtraWidgits
5+
import ExtraWidgits_for_Pathfinders
56
import StartProcess
67
import Rat_In_The_Maze
78
RunClock=True
@@ -37,8 +38,10 @@ def StartVisualization(self):
3738
font = pygame.font.SysFont('Comic Sans MS', 23)
3839
self.win.blit(font.render("Click on cells to create wall.", False, (255, 255, 255)), (670,50))
3940
self.win.blit(font.render("Press Space to START", False, (255, 255, 255)),(700,80))
40-
AddMainMenuButton = ExtraWidgits.MainMenuButton(self.win,700,300)
41+
42+
AddMainMenuButton = ExtraWidgits_for_Pathfinders.MainMenuButton(self.win,700,300)
4143
AddMainMenuButton.start()
44+
4245
AddExitText = ExtraWidgits.ExitText(self.win,725,250)
4346
AddExitText.start()
4447
self.CheckActions()
@@ -112,6 +115,7 @@ def make_Wall(self,x,y):
112115
return
113116
self.maze[row][col]^=1
114117
self.print_maze()
118+
115119
def print_maze(self):
116120
for y in range(self.n):
117121
if(not self.running):
@@ -127,22 +131,28 @@ def print_maze(self):
127131
self.win.blit(self.HOME, ((self.n-1) * self.block,(self.n-1) * self.block))
128132
except:
129133
pass
134+
130135
for i in range(self.n):
131136
if(not self.running):
132137
break
133-
#pygame.draw.rect(self.win,(0,0,0),(self.x_shift+i*self.block,self.y_shift+j*self.block,self.SIDE,10))
134-
#pygame.draw.rect(self.win,(0,0,0),(self.x_shift+i*self.block,self.y_shift+j*self.block,self.SIDE,10))
135-
pygame.draw.line(self.win,(0,0,0),(0,i*self.block),(self.SIDE,i*self.block),2)
136-
pygame.draw.line(self.win,(0,0,0),(i*self.block,0),(i*self.block,self.SIDE),2)
138+
139+
pygame.draw.line(self.win,(150,150,150),(0,i*self.block),(self.SIDE,i*self.block),2)
140+
pygame.draw.line(self.win,(150,150,150),(i*self.block,0),(i*self.block,self.SIDE),2)
137141
cur=[0,0]
142+
138143
for i in self.rat_pos[1:]:
139144
if(not self.running):
140145
break
141146
pygame.draw.line(self.win, (255, 0, 0), (self.block//2 + cur[0] * self.block, self.block//2 + cur[1] * self.block),
142147
(self.block//2+ i[0] * self.block,self.block//2+ i[1] * self.block), 5)
143148
cur=i
144-
pygame.draw.line(self.win,(255,0,0),(self.n*self.block,0),(self.n*self.block,self.SIDE),5)
149+
150+
pygame.draw.line(self.win,(150,150,150),(self.n*self.block,0),(self.n*self.block,self.SIDE),5)
145151
self.win.blit(self.RAT, (self.IMG_Pading + (self.rat_pos[-1][0]) * self.block, self.IMG_Pading + (self.rat_pos[-1][1]) * self.block))
152+
153+
update_canvas=pygame.Rect(0,0,600,600)
154+
pygame.display.update(update_canvas)
155+
146156
def find_way(self,x,y):
147157
self.operations+=1
148158
if(not self.running):

0 commit comments

Comments
 (0)