Daniel Bukač
Daniel Bukač

Reputation: 11

Why pygame.event.get() returns EventList?

Pygame.event is a queue. Usually, when I want to extract element from queue I expect it to return the element on the top, which is the first element, that entered the queue. Even Python's queue.get() works this way. So I'm wondering why pygame.event.get() returns list of all unprocessed events instead of returning the first event it got.

Upvotes: 1

Views: 253

Answers (1)

Rabbid76
Rabbid76

Reputation: 210996

Pygame has several options. Either use pygame.event.get() to get a list of all pending events or use pygame.event.poll() to get a single event from the queue. The returned events are removed from the queue.
It is even possible to wait for a single event by pygame.event.wait().

Upvotes: 2

Related Questions