Learn Before
Concept

Events in Pygame

Pygame registers a lot of different interactions from peripherals, such as mouse and keyboard, through events. It also registers certain actions, such as attempting to close the program, as an event. Events are objects which store a type (an int), describing what type of event it is, and potential additional attributes. Pygame stores the events in a queue--henceforth this will be referred to as the event queue. You can receive the queue yourself using a get method, and then decide what to do based on what the event was. For example, if the user pressed an arrow key on the keyboard, you could execute some method to move their character on the screen. Note that you can also do this by directly accessing the keyboard and mouse modules themselves, ignoring the event queue entirely.

0

1

Updated 2021-07-28

Tags

Python Programming Language

Data Science

Related