   [Python/Pygame] how to delay the game when receiving an event?
  how do I delay the main loop when receiving an event, and then continue after receiving another event?pygame.time.wait() only delays for a set amount of time..   
  I doubt you actually want to delay the main loop.I assume you wish to implement something like pause, right? It depends on the current structure of your main loop, but assuming you have something like the following:running = True...while running:    for evt in pygame.event.get():   # event handling    ...    # execute main loopthen it can be as simple as adding a new flag that determines whether to run the loop:running = Truepaused = False...while running:    for evt in pygame.event.get():   if evt.type == pygame.KEYDOWN:  if evt.key == pygame.P: paused = not paused    ...    if not paused:   # execute main loopEssentially, you add a new boolean flag that is toggled by the "delaying" event, and then you test that flag before executing your main loop iteration.   ;  I'm confused.. if I use a flag, how does the game continue?because the main loop depends on the flag, and if I pause it, and the main loop stops, how do I unpause it if I can't check for the KEYDOWN event?   ;  You don't need to put your key event checking in the same function as your overall game updates. Oluseyi demonstrates this in his example above. You still perform a loop that checks the events, just not updating the game each time if it's paused.   ;Quote:Original post by KylotanYou don't need to put your key event checking in the same function as your overall game updates. Oluseyi demonstrates this in his example above. You still perform a loop that checks the events, just not updating the game each time if it's paused.Indeed. Examine the example closely: operation of the overall loop, including event checking, is controlled by running (such that the program exits once running is false), but only the game logic update portion would be controlled by paused, since the portion that iterates over the event queue is outside of that if statement's body.   