January 2016
Intermediate to advanced
304 pages
6h 17m
English
Now that we have the game's main music, let's add some sounds effects to the mix! We've covered sf::Sound,sf::SoundBuffer, and how to play sounds, so we're ready to jump right in.
We're going to have a few sound effects in our game. One for the death of an enemy, one for us being hit, one for each pickup, and one for the sound of torches that we'll be playing with later.
We'll start by defining the sf::Sound variables for each sound in Game.h:
/** * Torch sound. */ sf::Sound m_fireSound; /** * Gem pickup sound. */ sf::Sound m_gemPickupSound; /** * Coin pickup sound. */ sf::Sound m_coinPickupSound; /** * Key collect sound. */ sf::Sound m_keyPickupSound; /** * Enemy die sound. */ sf::Sound m_enemyDieSound; /** * Player hit sound. ...
Read now
Unlock full access