Enough talk, action speaks louder than words. Let's add some background music to our game.
Open
WorldClass_00.py
from theChapter11
folder.Scroll down to the bottom of the
__init__
method and add the following four lines of code there:musicMgr = base.musicManager self.music = musicMgr.getSound( "../Sound/Loveshadow-Takin_Yo_Time_(The_Wingman_Mix).wav") self.music.setLoop(True) self.music.play()
Resave the file as
WorldClass_01.py
and run it from the command prompt.
Now we've got music! That's all there was to it. We just loaded the sound file into the AudioManager
with getSound
, set it to loop with setLoop(True)
, and told it to play with the play
method.
The song we loaded is called Takin Yo Time (The Wingman Mix)
and is by an artist named Loveshadow
. The song was released under a Creative Commons license that allows it to be used in commercial works as long as the artist receives credit for it. There are several...