mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-28 08:33:36 +00:00
Merge pull request #135 from AnonymusRaccoon/fix_sound_issue
add cache to sound
This commit is contained in:
@@ -11,10 +11,12 @@ namespace BBM
|
||||
float SoundComponent::volume = 0.75;
|
||||
|
||||
SoundComponent::SoundComponent(WAL::Entity &entity,
|
||||
const std::map<SoundComponent::SoundIndex, std::string> &soundPath)
|
||||
const std::map<SoundComponent::SoundIndex, std::string> &soundPath,
|
||||
bool isLonely)
|
||||
: WAL::Component(entity),
|
||||
_soundIndex(IDLE),
|
||||
_soundPath(soundPath)
|
||||
_soundPath(soundPath),
|
||||
_isLonely(isLonely)
|
||||
{
|
||||
for (int i = 0; i <= DEATH; i++) {
|
||||
this->_isSoundLoad[static_cast<SoundIndex>(i)] = false;
|
||||
@@ -22,7 +24,7 @@ namespace BBM
|
||||
for (auto &soundPath : soundPath)
|
||||
{
|
||||
this->_isSoundLoad[soundPath.first] = true;
|
||||
this->_soundList[soundPath.first] = std::make_unique<RAY::Audio::Sound>(soundPath.second);
|
||||
this->_soundList[soundPath.first] = std::make_unique<RAY::Audio::Sound>(soundPath.second, this->_isLonely);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,9 @@ namespace BBM
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
//! @brief Create a new SoundComponent at a certain Sound
|
||||
explicit SoundComponent(WAL::Entity &entity, const std::map<SoundIndex, std::string> &);
|
||||
explicit SoundComponent(WAL::Entity &entity,
|
||||
const std::map<SoundIndex, std::string> &,
|
||||
bool isLonely = false);
|
||||
//! @brief A Sound component is copy constructable
|
||||
SoundComponent(const SoundComponent &) = default;
|
||||
//! @brief A default destructor
|
||||
@@ -68,6 +70,8 @@ namespace BBM
|
||||
std::map<SoundIndex, std::shared_ptr<RAY::Audio::Sound>> _soundList;
|
||||
//! @brief map to know if sound is loaded
|
||||
std::map<SoundIndex, bool> _isSoundLoad;
|
||||
//! @brief to know if cache is needed
|
||||
bool _isLonely;
|
||||
//! @brief All sounds path
|
||||
const std::map<SoundIndex, std::string> _soundPath;
|
||||
//! SoundIndex
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace BBM
|
||||
{SoundComponent::JUMP, "assets/sounds/jump.wav"},
|
||||
{SoundComponent::MOVE, "assets/sounds/move.ogg"},
|
||||
{SoundComponent::BOMB, "assets/sounds/bomb_drop.ogg"},
|
||||
{SoundComponent::DEATH, "assets/sounds/death.ogg"}
|
||||
//{SoundComponent::DEATH, "assets/sounds/death.ogg"}
|
||||
};
|
||||
scene->addEntity("player")
|
||||
.addComponent<PositionComponent>()
|
||||
|
||||
Reference in New Issue
Block a user