Reputation: 11
I am implementing text in my code so that I will be tell the user exactly what is happening but there seems to be problems with the text showing on the pygame display especially when I call it.
I have already tried various methods of displaying text in the pygame window and it does not seem to work.
class maze(): def init(self,new): self.new = new self.walls = [] self.lab_walls = [] self.cells = []
a = 0
v = 0
for q in range(23):
for r in range(39):
deed = q in (0,1,2) and r > 60
if not deed:
self.cells.append(cell((a + 8, v, 25,8), (a + 8, v + 33, 25, 8), (a, v + 8, 8 ,25), (a + 33, v + 8, 8, 25)))
a += 33
a = 0
v += 33
for w in self.cells[0].walls:
self.lab_walls.append(w)
self.walls.append(w)
self.cells[0].view = True
while len(self.walls) > 0:
bounds = random.choice(self.walls)
divcells = []
for p in self.cells:
if bounds in p.walls:
divcells.append(p)
if len(divcells) > 1 and (not ((divcells[0].view and divcells[1].view) or ((not divcells[0].view) and (not divcells[1].view)))):
for g in divcells:
g.walls.remove(bounds)
if g.view == False:
g.view = True
for o in g.walls:
if not o in self.walls:
self.walls.append(o)
if not o in self.lab_walls:
self.lab_walls.append(o)
if bounds in self.lab_walls:
self.lab_walls.remove(bounds)
self.walls.remove(bounds)
for j in range(0, 789, 33):
for i in range(0, 1290, 33):
self.lab_walls.append((i, j, 8, 8))
def draw(self, win):
displaysurf.fill(WHITE)
for g in self.lab_walls:
pygame.draw.rect(displaysurf, BLACK, pygame.Rect(g[0], g[1], g[2], g[3]))
pygame.draw.rect(displaysurf, PURPLE, win)
The text is supposed to show on the pygame window but nothing shows apart from the background.
Upvotes: 0
Views: 58
Reputation: 7343
The problem is that you are rendering the label only in the initial render, but in your main loop you render the background, which basically clears the screen, so you need to render everything again for each frame. Move the line
screen.blit(label, (600,600))
Before the line
pygame.display.flip()
Upvotes: 2