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 — creating a method to load sounds

  1. Add the LoadSounds method to the game class.
    Method LoadSounds:Int ()
    
  2. Set the sound objects via calls to the engine's LoadSound method. The parameter is the filename of the sound, but without a file extension.
    sndExplo = eng.LoadSound("explosion")
    sndShot = eng.LoadSound("shoot1")
    
  3. Close the method:
    Return 0
    End
    

What just happened?

Even though we have only two sounds to load, with the LoadSounds method you have a code section that you can easily expand once you want to add more sounds to the game.

Did you see that score—the game UI

In every game, you have a user interface (UI) that will let you control the game somehow and also inform the player about certain statistics of the game. For example, how ...

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