Module 8 - Section 5 - spaceship
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)