O'Reilly logo

Learn Game Programming with Ruby by Mark Sobkowicz

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

Add Music and Sounds

Music and sounds help set a mood, add another dimension to your game, and make your game more polished. Let’s add a different background track to each scene and add sound effects for shooting and explosions. Gosu makes a distinction between background music, which plays for a long time, and sound effects, which are short. Background music is streamed, so the entire file does not need to be loaded into memory and is not synchronized with the game. Sound effects, or samples, are loaded into memory so that they can play at exactly the right moment in your game. It wouldn’t do to have a lag between the enemy exploding and the explosion sound.

Finding Sounds

What you need are electronic files of sounds in WAV or OGG format. If ...

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