I am using pygame and I want to display "Game Over" message before the window closes. For that I wanted to use time.sleep() function like that:
message('Game Over', red)
pygame.display.update()
time.sleep(3)
However it seems like time.sleep() delays the execution of pygame.display.update() and basically, the message appears after the delay instead of before. How can I ensure that time.sleep() is called only after the previous function is fully executed? Thank you in advance.