diff --git a/sources/Component/Sound/SoundComponent.cpp b/sources/Component/Sound/SoundComponent.cpp index 176230f8..d4ab53b1 100644 --- a/sources/Component/Sound/SoundComponent.cpp +++ b/sources/Component/Sound/SoundComponent.cpp @@ -14,16 +14,14 @@ std::map &soundPath) _soundIndex(IDLE), _soundPath(soundPath) { - for (int i = 0; i <= DEATH; i++) - this->_isLoad[static_cast(i)] = false; - /*for (int i = 0; i <= DEATH; i++) { + for (int i = 0; i <= DEATH; i++) { if (soundPath.at(static_cast(i)).empty()) { this->_isLoad[static_cast(i)] = false; } else { this->_isLoad[static_cast(i)] = true; - this->_soundList[static_cast(i)] = RAY::Audio::Sound(soundPath.at(static_cast(i))); + this->_soundList[static_cast(i)] = std::unique_ptr(new RAY::Audio::Sound(soundPath.at(static_cast(i)))); } - }*/ + } } SoundComponent::SoundComponent(WAL::Entity &entity) @@ -40,24 +38,24 @@ std::map &soundPath) void SoundComponent::playSound(void) { if (!this->_isLoad.at(this->_soundIndex)) - this->_soundList[this->_soundIndex] = RAY::Audio::Sound(this->_soundPath.at(this->_soundIndex)); - if (!this->_soundList[this->_soundIndex].isPlaying()) - this->_soundList[this->_soundIndex].play(); + return; + if (!this->_soundList[this->_soundIndex].get()->isPlaying()) + this->_soundList[this->_soundIndex].get()->play(); } void SoundComponent::stopSound(void) { if (!this->_isLoad.at(this->_soundIndex)) return; - if (this->_soundList[this->_soundIndex].isPlaying()) - this->_soundList[this->_soundIndex].stop(); + if (this->_soundList[this->_soundIndex].get()->isPlaying()) + this->_soundList[this->_soundIndex].get()->stop(); } void SoundComponent::pauseSound(void) { if (!this->_isLoad.at(this->_soundIndex)) return; - this->_soundList[this->_soundIndex].pause(); + this->_soundList[this->_soundIndex].get()->pause(); } void SoundComponent::setVolume(float &volume) @@ -65,21 +63,21 @@ std::map &soundPath) if (!this->_isLoad.at(this->_soundIndex)) return; if (volume >= 0) - this->_soundList[this->_soundIndex].setVolume(volume); + this->_soundList[this->_soundIndex].get()->setVolume(volume); } void SoundComponent::setPitch(float &pitch) { if (!this->_isLoad.at(this->_soundIndex)) return; - this->_soundList[this->_soundIndex].setPitch(pitch); + this->_soundList[this->_soundIndex].get()->setPitch(pitch); } bool SoundComponent::isPlaying(void) { if (!this->_isLoad.at(this->_soundIndex)) return (false); - return (this->_soundList[this->_soundIndex].isPlaying()); + return (this->_soundList[this->_soundIndex].get()->isPlaying()); } void SoundComponent::setIndex(soundIndex index) diff --git a/sources/Component/Sound/SoundComponent.hpp b/sources/Component/Sound/SoundComponent.hpp index df2d3925..e4b7ed5e 100644 --- a/sources/Component/Sound/SoundComponent.hpp +++ b/sources/Component/Sound/SoundComponent.hpp @@ -59,7 +59,7 @@ namespace BBM SoundComponent &operator=(const SoundComponent &) = delete; private: //! @brief Sound of this entity - std::map _soundList; + std::map> _soundList; std::map _isLoad; diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index d556b3b7..d4f9ccbd 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -70,7 +70,7 @@ namespace BBM auto scene = std::make_shared(); std::map soundPath= { {SoundComponent::IDLE, ""}, - {SoundComponent::JUMP, ""}, + {SoundComponent::JUMP, "assets/sounds/death.ogg"}, {SoundComponent::BOMB, ""}, {SoundComponent::MOVE, "assets/sounds/jump.wav"}, {SoundComponent::HURT, ""},