Nov-01-2023, 09:36 PM
This program records events when they occur, and then processes them one at a time, like happens when you use poll.
import pygame import time pygame.init() clock = pygame.time.Clock() screen = pygame.display.set_mode((200, 200)) events = [] max_delay = 0 event = [] while True: current_time = time.time() for event in pygame.event.get(): events.append((event, current_time)) if events: event, event_time = events.pop(0) delay = current_time - event_time if delay > max_delay: max_delay = delay print(delay) if event.type == pygame.QUIT: break clock.tick(60) pygame.quit()There are a lot of events that all happen as soon as the program starts running. You can see that each is delayed 1/60th of a second longer than the previous event.
Output:0.0009989738464355469
0.0180361270904541
0.034859418869018555
0.051959991455078125
0.06901097297668457
0.08533716201782227
0.10115480422973633
Wiggle the mouse around inside the window while mashing the mouse buttons and the delays can get bigger.Output:0.3165292739868164
0.3176705837249756
0.33345532417297363
1/3 of a second is forever in some games. In others it doesn't matter at all.