Game Development Reference
In-Depth Information
Figure 19-3: The Sprites and Sounds game.
Setting Up the Window and the Data Structure
Most of the code in this program was explained in the previous chapter, so we will only
focus on the parts that add sprites and sound.
12. pygame.display.set_caption('Sprites and Sound')
First, let's set the caption of the title bar to a string that describes this program. Pass the
string 'Sprites and Sound' to the pygame.display.set_caption()
function.
17. # set up the block data structure
18. player = pygame.Rect(300, 100, 40, 40)
19. playerImage = pygame.image.load('player.png')
20. playerStretchedImage = pygame.transform.scale
(playerImage, (40, 40))
21. foodImage = pygame.image.load('cherry.png')
We are going to use three different variables to represent the player, unlike the previous
programs that just used one. The player variable will store a Rect object that keeps
Search WWH ::




Custom Search