Hardware Reference
In-Depth Information
3.
The sounds that will be played when the game is launched or while the game
is in progress have to be loaded:
menu_sound = pygame.mixer.Sound('8-bit-circus-music.wav')
moves_sound = pygame.mixer.Sound('ding.wav')
The sounds are available under Creaive Commons License.
Ding hits
can be found at
https://www.freesound.org/people/
adcbicycle/sounds/13952/
and
8 Bit Circus Music
can be found
5.
In the main menu, let's play the
8-bit-circus-music
file in an infinite loop (unil
the user launches a game or exits the menu).
menu_sound.play(-1)
6. The parameter
-1
indicates that the files need to be filed in a loop.
7. In order to stop playing the sound, the
stop()
method has to be called before
launching the game:
menu_sound.stop() #stop playing the sound
runGame(isFirstGame)
8. The sound file is played in a loop once again after the game is over.
9. Similarly, the
ding
sound is played whenever the game AI (called the
computer
in the game) or the player has played a turn:
moves_sound.play() #Play ding sound
Objective complete - mission debriefing
We have completed the basic tweaks required for the game. In the next step, we will
interface the arcade style butons to the game.
Interfacing game inputs using the
PiFace module
In this task, we will review interfacing the arcade style butons (shown in the following
image) to Raspberry Pi to play the game. In this task, we will just discuss the software
part of the code.