O'Reilly logo

SFML Game Development By Example by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required