O'Reilly logo

Monkey Game Development by Michael Hartlef

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action — loading the game sound effects

  1. To load the sounds, add the LoadSound method to the game class.
    Method LoadSounds:Int()
    
  2. Load the non-looping sound effects.
    sndHit = eng.LoadSound("hit")
    sndExplo = eng.LoadSound("explosion")
    sndShoot = eng.LoadSound("shoot")
    
  3. The plane engine sound needs to be looped continuously. Add a TRUE parameter to the LoadSound call.
    sndEngine = eng.LoadSound("engine",True)
    
  4. Close this method.
    Return 0
    End
    

What just happened?

You have created a method that will load all sounds we need for the game. A file extension was not given to the LoadSound statement, as it will be added from fantomEngine, according to the platform on which you will build it. For the GLFW platform, you need WAV files.

Lay your head on me… the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required