A key part of PyGame coding is handling events.
Remember, we've already used events when we explored handling GUI events.
The PyGame module defines a number of events. Here's the list:
As you can see they cover keyboard, mouse and joystick actions plus the
quit event generated by closing the game window.
Importantly there's a
userevent which allows use to handle our own custom events.
A typical program will use at least one or two of these events. Later we'll create a function to handle these events.
A post from my Learn Python on the Raspberry Pi tutorial.