Functions and Event Handling - Introduction
Learning Goals
When you finish this lesson, you'll be able to do the following:
update()You can use functions to write code that runs every frameSequenceandFunc,WaitYou can use it to create repeating actionsinput()You can use functions to handle keyboard input- You can create particle effects by manipulating the vertices of a Mesh
Take a look at the code
Below is the code for a bullet-hell shooter game. Move the player with WASD and press the spacebar to fire bullets!
๐ Folder: five_functions / ๐ File: bullet_hell_functions.py
โก Don't remember how to run it? (click)
- Move to terminal:
cd ..aftercd folder_name - Run:
python filename.py(autocomplete with the Tab key) - Exit: Alt+F4 (Win) / Cmd+Q (Mac)
How to Control It
Most games use the standard control scheme:
- WASD Or Arrow keys: move
- Mouse: adjust view / aim
- Left click: shoot / interact
- Space: jump (platformer games)
- Tab: toggle slow motion (slow_motion.py)
- Escape: quit the game