In this adventure, you’ll learn how to use images with Python and PyGame
. During previous adventures you’ve used PyGame
’s drawing functions to draw shapes. You’ve discovered how flexible this is and how much it allows you to do, but it can’t do everything! Sometimes you will want to use images from other programs instead of drawing them with code.
During this adventure, you’ll create programs to load and layer images. You’ll create a program that lets you add a moustache to any image and another program to move a sprite around the window, which forms the basis of a game.
Loading an Image
The first thing you’ll do in this adventure is learn how to load and display an image. Before you can start, you’ll need to save your chosen images into the folder that the program will be saved in. In this adventure I’ve chosen the images for you. To download these images, follow the steps given in the Appendix.
Finished? Once you have the images, copy all of them into the Adventure 8
folder.
The first images you will be using are catSmall.png
, catLarge.png
, hat.png
and space.png
. Make sure they are in ...
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.