Added Component to bricks to emitt sound. Improved code for playing a sound
This commit is contained in:
@@ -111,6 +111,11 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
transform->Scale = glm::vec3(1.6, 0.35, 0.5);
|
||||
transform->Position = glm::vec3(x - 7, y + 1, -10.f);
|
||||
cBrick->Score = 10 * num;
|
||||
|
||||
//sound
|
||||
auto collisionSound = m_World->AddComponent<Components::CollisionSound>(brick);
|
||||
collisionSound->filePath = "Sounds/Brick/shortbrickbreak.wav";
|
||||
|
||||
m_World->CommitEntity(brick);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,21 @@ bool dd::Systems::SoundSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
|
||||
bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
int localBallEntID = 0;
|
||||
auto collisionSound = m_World->GetComponent<Components::CollisionSound>(event.Entity1);
|
||||
if (collisionSound == NULL) {
|
||||
collisionSound = m_World->GetComponent<Components::CollisionSound>(event.Entity2);
|
||||
if (collisionSound == NULL) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
dd::Events::PlaySFX e;
|
||||
e.path = collisionSound->filePath;
|
||||
EventBroker->Publish(e);
|
||||
return true;
|
||||
|
||||
|
||||
/*int localBallEntID = 0;
|
||||
//Make sure a ball is colliding
|
||||
auto ball = m_World->GetComponent<Components::Ball>(event.Entity1);
|
||||
if (ball == NULL) {
|
||||
@@ -117,7 +131,7 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
|
||||
e.path = "Sounds/Metal/impact.wav";
|
||||
EventBroker->Publish(e);
|
||||
return true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
ALuint dd::Systems::SoundSystem::CreateSource()
|
||||
|
||||
Reference in New Issue
Block a user