mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-06-06 19:22:20 +00:00
Sound for jump + fix sound component function name
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include "SoundComponent.hpp"
|
||||
|
||||
namespace BBM
|
||||
@@ -10,18 +11,18 @@ namespace BBM
|
||||
SoundComponent::SoundComponent(WAL::Entity &entity, \
|
||||
std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
: WAL::Component(entity),
|
||||
_soundIndex(IDLE)
|
||||
_soundIndex(IDLE),
|
||||
_soundPath(soundPath)
|
||||
{
|
||||
for (int i = 0; i < DEATH + 1; i++) {
|
||||
for (int i = 0; i <= DEATH; i++)
|
||||
this->_isLoad[static_cast<soundIndex>(i)] = false;
|
||||
/*for (int i = 0; i <= DEATH; i++) {
|
||||
if (soundPath.at(static_cast<soundIndex>(i)).empty()) {
|
||||
this->_isLoad[static_cast<soundIndex>(i)] = false;
|
||||
} else {
|
||||
this->_isLoad[static_cast<soundIndex>(i)] = true;
|
||||
this->_soundList[static_cast<soundIndex>(i)] = RAY::Audio::Sound(soundPath.at(static_cast<soundIndex>(i)));
|
||||
}
|
||||
}
|
||||
/*for (int i = 0; i < DEATH + 1; i++) {
|
||||
std::cout << i << this->_isLoad.at(static_cast<soundIndex>(i)) << soundPath.at(static_cast<soundIndex>(i)) << std::endl;
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -36,22 +37,19 @@ std::map<SoundComponent::soundIndex, std::string> &soundPath)
|
||||
return new SoundComponent(entity);
|
||||
}
|
||||
|
||||
void SoundComponent::loadSound(void)
|
||||
void SoundComponent::playSound(void)
|
||||
{
|
||||
std::cout << this->_soundIndex << std::endl;
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
return;
|
||||
if (!this->_soundList[this->_soundIndex].isPlaying()) {
|
||||
std::cout << this->_soundIndex << std::endl;
|
||||
this->_soundList[this->_soundIndex] = RAY::Audio::Sound(this->_soundPath.at(this->_soundIndex));
|
||||
if (!this->_soundList[this->_soundIndex].isPlaying())
|
||||
this->_soundList[this->_soundIndex].play();
|
||||
}
|
||||
}
|
||||
|
||||
void SoundComponent::unloadSound(void)
|
||||
void SoundComponent::stopSound(void)
|
||||
{
|
||||
if (!this->_isLoad.at(this->_soundIndex))
|
||||
return;
|
||||
if (!this->_soundList[this->_soundIndex].isPlaying())
|
||||
if (this->_soundList[this->_soundIndex].isPlaying())
|
||||
this->_soundList[this->_soundIndex].stop();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace BBM
|
||||
soundIndex getIndex();
|
||||
|
||||
//! @brief load Sound
|
||||
void loadSound();
|
||||
void playSound();
|
||||
|
||||
//! @brief unload Sound
|
||||
void unloadSound();
|
||||
void stopSound();
|
||||
|
||||
//! @brief put Sound on hold
|
||||
void pauseSound();
|
||||
@@ -47,11 +47,10 @@ namespace BBM
|
||||
//! @brief is Sound playing
|
||||
bool isPlaying(void);
|
||||
|
||||
|
||||
//! @inherit
|
||||
WAL::Component *clone(WAL::Entity &entity) const override;
|
||||
//! @brief Create a new SoundComponent at a certain Sound
|
||||
SoundComponent(WAL::Entity &entity, std::map<soundIndex, std::string> &SoundPath);
|
||||
SoundComponent(WAL::Entity &entity, std::map<soundIndex, std::string> &);
|
||||
//! @brief A Sound component is copy constructable
|
||||
SoundComponent(const SoundComponent &) = default;
|
||||
//! @brief A default destructor
|
||||
@@ -63,8 +62,13 @@ namespace BBM
|
||||
std::map<soundIndex, RAY::Audio::Sound> _soundList;
|
||||
|
||||
std::map<soundIndex, bool> _isLoad;
|
||||
|
||||
std::map<soundIndex, std::string> _soundPath;
|
||||
|
||||
//! SoundIndex
|
||||
soundIndex _soundIndex;
|
||||
|
||||
|
||||
//! @brief Create a new SoundComponent linked to a specific entity
|
||||
explicit SoundComponent(WAL::Entity &entity);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user