Playing the rest of the sounds
Now, we will add the rest of the calls to the play
function. We will deal with each of them individually, as locating exactly where they go is key to playing them at the right moment.
Adding sound effects while the player is reloading
Add the following highlighted code in three places to play the appropriate reload
or reloadFailed
sound when the player presses the R key to attempt to reload their gun:
if (state == State::PLAYING) { // Reloading if (event.key.code == Keyboard::R) { if (bulletsSpare >= clipSize) { // Plenty of bullets. Reload. bulletsInClip = clipSize; ...