User Interaction
There are two main ways to interact with the game: the mouse and the keyboard.
Mouse Input
We'll create an image and assign it to track the mouse position.
We can also detect the state of specific mouse buttons. We'll tint the image whenever the left mouse button is held down.
Mouse buttons also have two extra attributes: press and release. They are triggered the moment a mouse button is pressed or released.
Mouse Movement
Sometimes, you'll want to detect when the mouse moves. The mouse.move attribute can be interpreted as a bool or the x and y movement of the mouse.
if mouse.move: # mouse is moving print(mouse.move.x, mouse.move.y)
Keyboard Input
Keyboard buttons are similar to mouse buttons. Let's tint our image every time the space key is held down.
Just like mouse buttons, each key has a press and release attribute. There's also an extra one, repeat, which is triggered at intervals when the user holds the key for a certain amount of time.
There are many other keys that support this feature.
Keyboard Scancodes
Coming soon
Keyboard Modifiers
Coming soon