Controlling sprites with the keyboard
This tutorial will show you how to control sprites with the keyboard in Pygame. Download and open the file below.
keyboardcontrols.py | |
File Size: | 1 kb |
File Type: | py |
Tasks
1. Why does the code for the right arrow work better than the left?
2. Change the code so the left arrow works the same as the right.
3. Add code so the sprite jumps when the up arrow is pressed
4. Add code so the sprite crouches (rectangle should become half height) when the down arrow is pressed
2. Change the code so the left arrow works the same as the right.
3. Add code so the sprite jumps when the up arrow is pressed
4. Add code so the sprite crouches (rectangle should become half height) when the down arrow is pressed
Further tasks
Try to improve your jump code using the example code linked below:
https://github.com/seanmtracey/Games-with-Pygame/blob/master/Part%203/keyboard.py |