O'Reilly logo

Procedural Content Generation for C++ Game Development by Dale Green

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

3D sound – spatialization

Now let's look at ways to create some 3D audio to bring depth to a game scene. When we walk past a torch, we want to hear it move past us, and we want to be able to hear our enemies coming at us from a direction. Spatialization allows us to do this, and SFML has great features to help us achieve that.

The audio listener

We've already defined what the audio listener is and how it is used to create spatialized audio. As the first step toward achieving this, we need to set the position of the listener after each update, ensuring that all the sounds in the level are heard from the player's perspective.

At the start of each game's update, we recalculate the player's position. Right after this we can update the position of 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