Basically, my main idea is that we would program most of the entire game in a while loop (except when constructing a screen). When the game ends, I let the user enter another while loop so that the player is getting the chance to click the mouse (which starts the game over) while in the loop. The loop I coded is below. However, the screen keeps freezing (i.e. the mouse press method never works) without any errors. I don’t know why it’s happening.
while not pygame.mouse.get_pressed()[0]:
clock.tick(20)
background_image = pygame.image.load("GameOver.jpg").convert()
When the mouse is pressed, the while loop guiding the rest of the game goes over once again. Please ask if you’re confused about anything about my problem.
You need to be sure you’re calling pygame.event.get() to get the events from the cue before checking for pygame.mouse.get_pressed() or it will not work.
It’s a bit difficult to suggest where to put into your code without seeing what’s around it but basically:
You may find it is easier to just set a flag when they enter this mode and check on the flag instead of creating another while loop.