Adding support for sound

In order to make our entities emit sounds, some preparations have to be made. For now, we're only going to concern ourselves with simply adding the sound of footsteps whenever a character walks. Doing so requires a slight modification of the EntityMessage enumeration in EntityMessages.h:

enum class EntityMessage{ 
  Move, Is_Moving, Frame_Change, State_Changed, Direction_Changed,
  Switch_State, Attack_Action, Dead
};

The highlighted bits are what we're going to be focusing on. Frame_Change is a new type of message that's been added in this chapter, and Direction_Changed will be used to manipulate the sound listener's direction. In order to detect when a frame changes during the animation process, however, we're going to need ...

Get SFML Game Development By Example 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.