Loads BGM and SFX sounds differently depending on path to sound file.
This commit is contained in:
+16
-1
@@ -4,7 +4,22 @@
|
|||||||
|
|
||||||
Sound::Sound(std::string path, FMOD_SYSTEM* system)
|
Sound::Sound(std::string path, FMOD_SYSTEM* system)
|
||||||
{
|
{
|
||||||
FMOD_System_CreateSound(system, path.c_str(), FMOD_3D, NULL, &m_Sound);
|
|
||||||
|
std::string str = "";
|
||||||
|
for(int i = 7; i < 10; i++)
|
||||||
|
{
|
||||||
|
str += path[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(str == "BGM")
|
||||||
|
{
|
||||||
|
FMOD_System_CreateSound(system, path.c_str(), FMOD_2D, NULL, &m_Sound);
|
||||||
|
}
|
||||||
|
if (str == "SFX")
|
||||||
|
{
|
||||||
|
FMOD_System_CreateSound(system, path.c_str(), FMOD_3D, NULL, &m_Sound);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound::~Sound()
|
Sound::~Sound()
|
||||||
|
|||||||
+14
-13
@@ -89,18 +89,17 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
|
|||||||
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
auto eTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||||
|
|
||||||
|
|
||||||
if(emitter->type == emitter->BGM_SOUND)
|
// if(emitter->type == emitter->BGM_SOUND)
|
||||||
{
|
// {
|
||||||
|
//
|
||||||
EntityID listener = m_Listeners[0]; // "Pretty" ugly hack... Sets the transform Component for emitter to be same as first listener
|
// EntityID listener = m_Listeners[0]; // "Pretty" ugly hack... Sets the transform Component for emitter to be same as first listener
|
||||||
auto lTransform = m_World->GetComponent<Components::Transform>(listener);
|
// auto lTransform = m_World->GetComponent<Components::Transform>(listener);
|
||||||
if(lTransform)
|
// if(lTransform)
|
||||||
{
|
// {
|
||||||
eTransform->Position = m_TransformSystem->AbsolutePosition(listener);
|
// eTransform->Position = m_TransformSystem->AbsolutePosition(listener);
|
||||||
eTransform->Velocity = lTransform->Velocity;
|
// eTransform->Velocity = lTransform->Velocity;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
|
||||||
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
glm::vec3 tPos = m_TransformSystem->AbsolutePosition(entity);
|
||||||
FMOD_VECTOR ePos = {tPos.x, tPos.y, tPos.z};
|
FMOD_VECTOR ePos = {tPos.x, tPos.y, tPos.z};
|
||||||
|
|
||||||
@@ -151,6 +150,9 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
|||||||
|
|
||||||
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
PlaySound(&m_Channels[event.Emitter], m_Sounds[event.Emitter], 1.0, event.Loop);
|
||||||
FMOD_System_Update(m_System);
|
FMOD_System_Update(m_System);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FMOD_BOOL isPlaying = false;
|
FMOD_BOOL isPlaying = false;
|
||||||
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
FMOD_Channel_IsPlaying(m_Channels[event.Emitter], &isPlaying);
|
||||||
if(!isPlaying)
|
if(!isPlaying)
|
||||||
@@ -163,7 +165,6 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
|
|||||||
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
|
||||||
{
|
{
|
||||||
auto emitter = m_World->CreateEntity();
|
auto emitter = m_World->CreateEntity();
|
||||||
std::cout<<"ASSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS: "<<emitter<<std::endl;
|
|
||||||
auto eTransform = m_World->AddComponent<Components::Transform>(emitter);
|
auto eTransform = m_World->AddComponent<Components::Transform>(emitter);
|
||||||
|
|
||||||
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(emitter);
|
auto eComponent = m_World->AddComponent<Components::SoundEmitter>(emitter);
|
||||||
|
|||||||
Reference in New Issue
Block a user