Book
Module 8 - Section 5 - spaceship
Module 8 - Section 5 - spaceship
Completion requirements
View
After the completion of this module the students will be able to:
- identify various classes inside Python code game
- describe the parts of the class and it's use
- identify the objects of a class
- recognize the characteristics and the values of the objects
- modify the code of the game to make it easier or harder
8.5.5 - Background
To change the background from a dull color to an image we need:
- An image of our choice as a background
- A command to convert the image for the pygame
- A command to blit the image instead of filling with uniform color
For the background image download it from here and save it as background.jpg inside the working folder.
The commands to draw the background are:
background_image = pygame.image.load("background.jpg").convert()
before the main loop but after the screen's set mode and :
screen.blit(background_image, [0, 0])
instead of screen.fill(COLOR) command inside the main loop. The code can be downloaded from here (avoid_v0.8.0.py)