mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-01 17:55:48 +00:00
fix little beauty issues
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -10,18 +10,18 @@ namespace BBM
|
||||
{
|
||||
float SoundComponent::volume = 0.75;
|
||||
|
||||
SoundComponent::SoundComponent(WAL::Entity &entity, \
|
||||
const std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
SoundComponent::SoundComponent(WAL::Entity &entity,
|
||||
const std::map<SoundComponent::SoundIndex, std::string> &soundPath)
|
||||
: WAL::Component(entity),
|
||||
_soundIndex(IDLE),
|
||||
_soundPath(soundPath)
|
||||
{
|
||||
for (int i = 0; i <= DEATH; i++) {
|
||||
this->_isLoad[static_cast<soundIndex>(i)] = false;
|
||||
this->_isSoundLoad[static_cast<SoundIndex>(i)] = false;
|
||||
}
|
||||
for (auto &soundPath : soundPath)
|
||||
{
|
||||
this->_isLoad[soundPath.first] = true;
|
||||
this->_isSoundLoad[soundPath.first] = true;
|
||||
this->_soundList[soundPath.first] = std::make_unique<RAY::Audio::Sound>(soundPath.second);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ const std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
|
||||
void SoundComponent::playSound()
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return;
|
||||
if (!this->_soundList[this->_soundIndex].get()->isPlaying())
|
||||
this->_soundList[this->_soundIndex].get()->play();
|
||||
@@ -41,7 +41,7 @@ const std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
|
||||
void SoundComponent::stopSound()
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return;
|
||||
if (this->_soundList[this->_soundIndex].get()->isPlaying())
|
||||
this->_soundList[this->_soundIndex].get()->stop();
|
||||
@@ -49,40 +49,41 @@ const std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
|
||||
void SoundComponent::pauseSound()
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return;
|
||||
this->_soundList[this->_soundIndex].get()->pause();
|
||||
}
|
||||
|
||||
void SoundComponent::setVolume(float &volumeUpdate)
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return;
|
||||
if (volumeUpdate >= 0)
|
||||
if (volumeUpdate >= 0) {
|
||||
this->volume = volumeUpdate;
|
||||
this->_soundList[this->_soundIndex].get()->setVolume(this->volume);
|
||||
}
|
||||
}
|
||||
|
||||
void SoundComponent::setPitch(float &pitch)
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return;
|
||||
this->_soundList[this->_soundIndex].get()->setPitch(pitch);
|
||||
}
|
||||
|
||||
bool SoundComponent::isPlaying()
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
if (!this->_isSoundLoad.at(this->_soundIndex))
|
||||
return (false);
|
||||
return (this->_soundList[this->_soundIndex].get()->isPlaying());
|
||||
}
|
||||
|
||||
void SoundComponent::setIndex(soundIndex index)
|
||||
void SoundComponent::setIndex(SoundIndex index)
|
||||
{
|
||||
this->_soundIndex = index;
|
||||
}
|
||||
|
||||
SoundComponent::soundIndex SoundComponent::getIndex()
|
||||
SoundComponent::SoundIndex SoundComponent::getIndex()
|
||||
{
|
||||
return (this->_soundIndex);
|
||||
}
|
||||
|
||||
@@ -16,21 +16,21 @@ namespace BBM
|
||||
public:
|
||||
|
||||
//! @brief All sounds of the player
|
||||
enum soundIndex {
|
||||
enum SoundIndex {
|
||||
IDLE,
|
||||
JUMP,
|
||||
BOMB,
|
||||
MOVE,
|
||||
HURT,
|
||||
THROW,
|
||||
DEATH,
|
||||
DEATH
|
||||
};
|
||||
|
||||
//! @brief to set what sound should be played
|
||||
void setIndex(soundIndex index);
|
||||
void setIndex(SoundIndex index);
|
||||
|
||||
//! @brief to know which sound is selected
|
||||
soundIndex getIndex();
|
||||
SoundIndex getIndex();
|
||||
|
||||
//! @brief start sound
|
||||
void playSound();
|
||||
@@ -53,7 +53,7 @@ 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> &);
|
||||
//! @brief A Sound component is copy constructable
|
||||
SoundComponent(const SoundComponent &) = default;
|
||||
//! @brief A default destructor
|
||||
@@ -65,13 +65,13 @@ namespace BBM
|
||||
|
||||
private:
|
||||
//! @brief Sounds of this entity
|
||||
std::map<soundIndex, std::shared_ptr<RAY::Audio::Sound>> _soundList;
|
||||
std::map<SoundIndex, std::shared_ptr<RAY::Audio::Sound>> _soundList;
|
||||
//! @brief map to know if sound is loaded
|
||||
std::map<soundIndex, bool> _isLoad;
|
||||
std::map<SoundIndex, bool> _isSoundLoad;
|
||||
//! @brief All sounds path
|
||||
const std::map<soundIndex, std::string> _soundPath;
|
||||
const std::map<SoundIndex, std::string> _soundPath;
|
||||
//! SoundIndex
|
||||
soundIndex _soundIndex;
|
||||
SoundIndex _soundIndex;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user