The sound emitter component

Within the entity component system paradigm, every possible entity parameter or feature is represented as a component. Emitting sounds is definitely one of those features. In order for that to happen, we do have some setting up to do, starting with creating and implementing it in the C_SoundEmitter.h header. Before that, however, let's define the types of sounds an entity can have:

enum class EntitySound{ None = -1, Footstep, Attack, Hurt,Death };

As you can see, we're only going to be working with four types of sound, one of which is going to be implemented in this chapter. A None value is also set up in order to make error checking easier.

Every sound that an entity can emit will most likely have different frames it ...

Get SFML Game Development By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.