Okay so basically I have some code that checks to see if a "finish" button is clicked. the way I have it set up is a while loop that has an event for loop to see if the button is clicked by checking the coordinates of the click. when the done button is clicked it should call my next function and the button should disappear (which it does, Its just the last while loop is still listening for my clicks or something). BUT for some reason when I go to the next screen where my results are printing and click in the coordinates of the button (even tho its not there) it will still click it and show up again.
Here is some pseudo-code of what its like:
def findSomething():
#main block of code more than what is here
#I am just showing how I set up the surface
surface = pygame.display.set_mode((400, 300))
background_colour = (18,18,19)
surface.fill(background_colour)
#button code
while running:
pygame.display.flip()
for event in pygame.event.QUIT:
if event.type == pygame.QUIT:
pygame.quit()
quit()
if event.type == pygame.MOUSEBUTTONDOWN:
x,y = pygame.mouse.get_pos()
if 125 <= x <= 275 and 190 <= y <= 240:
print("clicked done")
printOptions()
def printOptions():
surface = pygame.display.set_mode((400, 700))
background_colour = (18,18,19)
surface.fill(background_colour)
phraseGuess = buttonFont.render(("Remaining Words: "), True, white)
surface.blit(phraseGuess, (25, 50))
#code for printing stuff out
so Im not sure why its still checking for clicks after i call printOptions(). is there a way to exit the loop while simultaneously calling printOptions() and still having it work? Or is there something I can do at the top of the printOptions function to kind of reset the display and stop looking for clicks in that certain spot?