From ff7d9d411b36cf018278c98b661e88714442fab8 Mon Sep 17 00:00:00 2001 From: Askou Date: Wed, 9 Jun 2021 09:53:28 +0200 Subject: [PATCH] full map not needed anymore --- sources/Component/Music/MusicComponent.cpp | 8 ++++---- sources/Component/Sound/SoundComponent.cpp | 19 +++++++++---------- sources/Runner/Runner.cpp | 6 +----- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/sources/Component/Music/MusicComponent.cpp b/sources/Component/Music/MusicComponent.cpp index 8d2656e3..40dc33b1 100644 --- a/sources/Component/Music/MusicComponent.cpp +++ b/sources/Component/Music/MusicComponent.cpp @@ -7,16 +7,15 @@ namespace BBM { + float MusicComponent::volume = 0.75; + MusicComponent::MusicComponent(WAL::Entity &entity, const std::string &musicPath) : WAL::Component(entity), _musicPath(musicPath), _music(RAY::Audio::Music(musicPath)) { - this->volume = 1; } - float MusicComponent::volume; - WAL::Component *MusicComponent::clone(WAL::Entity &entity) const { return new MusicComponent(entity, this->_musicPath); @@ -43,7 +42,8 @@ namespace BBM void MusicComponent::setVolume(float &volumeUpdate) { if (volumeUpdate >= 0) { - this->_music.setVolume(volume); + this->volume = volumeUpdate; + this->_music.setVolume(this->volume); } } diff --git a/sources/Component/Sound/SoundComponent.cpp b/sources/Component/Sound/SoundComponent.cpp index b74fcc9b..f3c18292 100644 --- a/sources/Component/Sound/SoundComponent.cpp +++ b/sources/Component/Sound/SoundComponent.cpp @@ -7,26 +7,25 @@ #include "SoundComponent.hpp" namespace BBM -{ +{ + float SoundComponent::volume = 0.75; + SoundComponent::SoundComponent(WAL::Entity &entity, \ const std::map &soundPath) : WAL::Component(entity), _soundIndex(IDLE), _soundPath(soundPath) { - this->volume = 1; 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)] = std::make_unique(soundPath.at(static_cast(i))); - } + this->_isLoad[static_cast(i)] = false; + } + for (auto &soundPath : soundPath) + { + this->_isLoad[soundPath.first] = true; + this->_soundList[soundPath.first] = std::make_unique(soundPath.second); } } - float SoundComponent::volume; - WAL::Component *SoundComponent::clone(WAL::Entity &entity) const { return new SoundComponent(entity, this->_soundPath); diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 1936d978..4e324535 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -67,7 +67,7 @@ namespace BBM void enableRaylib(WAL::Wal &wal) { - //RAY::TraceLog::setLevel(LOG_WARNING); + RAY::TraceLog::setLevel(LOG_WARNING); RAY::Window &window = RAY::Window::getInstance(600, 400, "Bomberman", FLAG_WINDOW_RESIZABLE); wal.addSystem() .addSystem() @@ -78,12 +78,8 @@ namespace BBM { auto scene = std::make_shared(); std::map soundPath= { - {SoundComponent::IDLE, ""}, {SoundComponent::JUMP, "assets/sounds/jump.wav"}, {SoundComponent::BOMB, "assets/sounds/bomb_drop.ogg"}, - {SoundComponent::MOVE, "assets/sounds/jump.wav"}, - {SoundComponent::HURT, ""}, - {SoundComponent::THROW, ""}, {SoundComponent::DEATH, "assets/sounds/death.ogg"} }; scene->addEntity("player")