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 ...
Get Procedural Content Generation for C++ Game Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.