Implementing situational sound effects
Ever noticed how almost anything that you do in games produces some kind of sound effect? It could be as simple as a "ding!" every time you collect gold or a complex series of explosions coming from your speakers, but in the best games, a lot of thought and planning goes into sound design because it is really important to the experience. Sound in games, at its core, is meant to inform the player of something happening. If the sound doesn't match the action, it can break a player's engagement with the game world. You've likely played a game with poor sound design; you might not remember it, but you surely remember the games that did it right. Let's take a look at how we can create audible responses to accompany in-game events.
Getting ready
For this recipe, we're going to reuse some of the movement code from Chapter 2, It's Under Control – Exploring Various Control Schemes. If you skipped the Making your character jump recipe; don't worry, I've copied...