Upgrading the SoundEngine class
Let’s add some new functionality to the SoundEngine class and start adding the spatialization features for real.
The first addition to the SoundEngine class is some new member variables. In SoundEngine.h add these two members to the private section:
static SoundBuffer mFireballLaunchBuffer;
static Sound mFireballLaunchSound;
We now have a new SoundBuffer to load a sound into and a new Sound instance to associate with the SoundBuffer instance and play the sound. There is nothing new here except to remember that the sound we load into mFireballLaunchBuffer must be mono for the spatialization to work.
Next, add the following function declaration to the public section of SoundEngine.h:
static void playFireballLaunch(
Vector2f playerPosition,
Vector2f soundLocation);
The preceding code playFireballLaunch function declaration takes a Vector2f for the player’s location and a Vector2f for the location where we want...