Here are some key points about what we learned in this last chapter:
- Sounds are short audio effects that may be played as a result of something happening in a game. For example, if a character jumped in a game, there may be a stomping sound. In pygame, you can load a sound from a file by doing
sound = pygame.mixer.Sound("sound.wav"), and you can play the sound by doing
- Music is long audio that may be played in the background of a game. This is like the piano soundtracks in the popular game called Minecraft. In pygame, you can load music from a file by doing
pygame.mixer.music.load("jazz.wav"), and you can play the music by doing
pygame.mixer.music.play(-1). The number in the parenthesis determines how long the music is played.