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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.