WHEN YOU’RE PLAYING computer games on your PC, one of the ways you can give the game commands is via the keyboard. You use different keys to give different commands—for example, you usually use the W, A, S and D keys to move the player around the game.
In this adventure you’ll learn how to use the keyboard with PyGame
. You’ll also make a game in which, for the first time, you’ll move a player around the window. Okay—your player is just a dot on the screen at this stage, but it’s a good start! As the program develops throughout the adventure, you’ll add extra features like a ball that your player can “kick,” a goal and a points system.
The gameplay and graphics in this game are very simple, so during the adventure you may want to add more features to the game, like better graphics. Try using some of the things you learned in Adventure 5 to add that little bit extra to the game. You can also come back to the game and improve it after you’ve learned more in later adventures. You’ll be learning lots in the sound adventure in Adventure 9, for example, so you can add sound to the game once you know how to do that.
Using Keyboard Input
Get Adventures in Python now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.