Bomberman
SoundComponent.hpp
Go to the documentation of this file.
1 //
2 // Created by Tom Augier on 05/06/2021
3 //
4 
5 #pragma once
6 
8 #include <map>
9 #include "Audio/Sound.hpp"
10 
11 namespace BBM
12 {
15  {
16  public:
17 
19  enum SoundIndex {
27  };
28 
30  void setIndex(SoundIndex index);
31 
34 
36  void playSound();
37 
39  void stopSound();
40 
42  void pauseSound();
43 
45  void setVolume(float);
46 
48  void turnDownVolume();
49 
51  void turnUpVolume();
52 
54  void setPitch(float);
55 
57  bool isPlaying();
58 
60  WAL::Component *clone(WAL::Entity &entity) const override;
62  explicit SoundComponent(WAL::Entity &entity,
63  const std::map<SoundIndex, std::string> &,
64  bool isLonely = false);
66  SoundComponent(const SoundComponent &) = default;
68  ~SoundComponent() override = default;
70  SoundComponent &operator=(const SoundComponent &) = delete;
72  static float volume;
73 
74  private:
76  std::map<SoundIndex, std::shared_ptr<RAY::Audio::Sound>> _soundList;
78  std::map<SoundIndex, bool> _isSoundLoad;
80  bool _isLonely;
82  const std::map<SoundIndex, std::string> _soundPath;
85 
86  };
87 
88 } // namespace BBM
BBM::SoundComponent::_soundIndex
SoundIndex _soundIndex
SoundIndex.
Definition: SoundComponent.hpp:84
BBM::SoundComponent::setIndex
void setIndex(SoundIndex index)
to set what sound should be played
Definition: SoundComponent.cpp:82
BBM::SoundComponent::DEATH
@ DEATH
Definition: SoundComponent.hpp:26
BBM::SoundComponent::BOMB
@ BOMB
Definition: SoundComponent.hpp:22
BBM::SoundComponent::~SoundComponent
~SoundComponent() override=default
A default destructor.
BBM::SoundComponent::SoundIndex
SoundIndex
All sounds of the player.
Definition: SoundComponent.hpp:19
BBM::SoundComponent::turnDownVolume
void turnDownVolume()
volume -= 0.1
Definition: SoundComponent.cpp:92
BBM::SoundComponent::IDLE
@ IDLE
Definition: SoundComponent.hpp:20
BBM::SoundComponent::_soundList
std::map< SoundIndex, std::shared_ptr< RAY::Audio::Sound > > _soundList
Sounds of this entity.
Definition: SoundComponent.hpp:76
WAL::Component
Represent a single component of WAL.
Definition: Component.hpp:17
BBM
Definition: AnimationsComponent.cpp:9
BBM::SoundComponent::isPlaying
bool isPlaying()
is Sound playing
Definition: SoundComponent.cpp:75
WAL::Entity
An entity of the WAL's ECS.
Definition: Entity.hpp:20
BBM::SoundComponent::getIndex
SoundIndex getIndex()
to know which sound is selected
Definition: SoundComponent.cpp:87
BBM::SoundComponent::turnUpVolume
void turnUpVolume()
volume += 0.1
Definition: SoundComponent.cpp:97
BBM::SoundComponent::HURT
@ HURT
Definition: SoundComponent.hpp:24
Component.hpp
BBM::SoundComponent::SoundComponent
SoundComponent(WAL::Entity &entity, const std::map< SoundIndex, std::string > &, bool isLonely=false)
Create a new SoundComponent at a certain Sound.
Sound.hpp
BBM::SoundComponent::clone
WAL::Component * clone(WAL::Entity &entity) const override
Clone a component for another or the same entity.
Definition: SoundComponent.cpp:31
BBM::SoundComponent::operator=
SoundComponent & operator=(const SoundComponent &)=delete
A Sound component is not assignable.
BBM::SoundComponent::stopSound
void stopSound()
stop sound
Definition: SoundComponent.cpp:44
BBM::SoundComponent::playSound
void playSound()
start sound
Definition: SoundComponent.cpp:36
BBM::SoundComponent::setPitch
void setPitch(float)
set pitch volume
Definition: SoundComponent.cpp:68
BBM::SoundComponent::volume
static float volume
Volume of the sounds.
Definition: SoundComponent.hpp:72
BBM::SoundComponent::_isLonely
bool _isLonely
to know if cache is needed
Definition: SoundComponent.hpp:80
BBM::SoundComponent::pauseSound
void pauseSound()
put Sound on hold
Definition: SoundComponent.cpp:52
BBM::SoundComponent::_isSoundLoad
std::map< SoundIndex, bool > _isSoundLoad
map to know if sound is loaded
Definition: SoundComponent.hpp:78
BBM::SoundComponent::MOVE
@ MOVE
Definition: SoundComponent.hpp:23
BBM::SoundComponent
A basic Sound component.
Definition: SoundComponent.hpp:14
BBM::SoundComponent::THROW
@ THROW
Definition: SoundComponent.hpp:25
BBM::SoundComponent::JUMP
@ JUMP
Definition: SoundComponent.hpp:21
BBM::SoundComponent::setVolume
void setVolume(float)
set Sound volume
Definition: SoundComponent.cpp:59
BBM::SoundComponent::_soundPath
const std::map< SoundIndex, std::string > _soundPath
All sounds path.
Definition: SoundComponent.hpp:82