Chapter 17: User Input Handling

This chapter covers the design and implementation of a system that processes user input to interact with your game.

Our input handler (InputHandler) class is responsible for capturing and maintaining the state of the inputs. It handles keyboard and mouse input and even game controller input.

It first initializes an EventPump to process events and a game controller if any. It keeps track of the keys that are currently pressed and the mouse state, including position and whether the left button is pressed. It can provide the current state of a key or controller button, the mouse button state and position, and poll events that have occurred.

Last updated