diff --git a/assets/Sounds/Brick/Debris Brick_RBD 02.wav b/assets/Sounds/Brick/Debris Brick_RBD 02.wav new file mode 100644 index 0000000..31d62ff Binary files /dev/null and b/assets/Sounds/Brick/Debris Brick_RBD 02.wav differ diff --git a/assets/Sounds/Brick/Drop Rock On Rock Debris_RBD 03.wav b/assets/Sounds/Brick/Drop Rock On Rock Debris_RBD 03.wav new file mode 100644 index 0000000..1530489 Binary files /dev/null and b/assets/Sounds/Brick/Drop Rock On Rock Debris_RBD 03.wav differ diff --git a/assets/Sounds/Brick/Hit Rock Debris_RBD 02.wav b/assets/Sounds/Brick/Hit Rock Debris_RBD 02.wav new file mode 100644 index 0000000..b19e119 Binary files /dev/null and b/assets/Sounds/Brick/Hit Rock Debris_RBD 02.wav differ diff --git a/assets/Sounds/Brick/IceBlocks,impact,cracked,tinypieces,scatter,slide,concrete,chunky,ambiance.M.wav b/assets/Sounds/Brick/IceBlocks,impact,cracked,tinypieces,scatter,slide,concrete,chunky,ambiance.M.wav new file mode 100644 index 0000000..d3516b6 Binary files /dev/null and b/assets/Sounds/Brick/IceBlocks,impact,cracked,tinypieces,scatter,slide,concrete,chunky,ambiance.M.wav differ diff --git a/assets/Sounds/Brick/brickBreak.wav b/assets/Sounds/Brick/brickBreak.wav new file mode 100644 index 0000000..31d62ff Binary files /dev/null and b/assets/Sounds/Brick/brickBreak.wav differ diff --git a/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various05.wav b/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various05.wav new file mode 100644 index 0000000..a6eb87f Binary files /dev/null and b/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various05.wav differ diff --git a/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various16.wav b/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various16.wav new file mode 100644 index 0000000..5e84102 Binary files /dev/null and b/assets/Sounds/Jelly/Borax,Impact,Slime,Gore,Various16.wav differ diff --git a/assets/Sounds/Jelly/Bread,Pizza,Curst,Crunch,Focaccia,Baked,Burnt,Various02.wav b/assets/Sounds/Jelly/Bread,Pizza,Curst,Crunch,Focaccia,Baked,Burnt,Various02.wav new file mode 100644 index 0000000..936fdd4 Binary files /dev/null and b/assets/Sounds/Jelly/Bread,Pizza,Curst,Crunch,Focaccia,Baked,Burnt,Various02.wav differ diff --git a/assets/Sounds/Jelly/EFX INT Meat drops 03 B.wav b/assets/Sounds/Jelly/EFX INT Meat drops 03 B.wav new file mode 100644 index 0000000..3baafa0 Binary files /dev/null and b/assets/Sounds/Jelly/EFX INT Meat drops 03 B.wav differ diff --git a/assets/Sounds/Jelly/Jelly,Movement,Gore,Liquid,Splat,Impact,Slime,Various09.wav b/assets/Sounds/Jelly/Jelly,Movement,Gore,Liquid,Splat,Impact,Slime,Various09.wav new file mode 100644 index 0000000..34190b4 Binary files /dev/null and b/assets/Sounds/Jelly/Jelly,Movement,Gore,Liquid,Splat,Impact,Slime,Various09.wav differ diff --git a/assets/Sounds/Jelly/gore - flesh guts gore impact blood squirt wet - hard - 49.wav b/assets/Sounds/Jelly/gore - flesh guts gore impact blood squirt wet - hard - 49.wav new file mode 100644 index 0000000..ec98b28 Binary files /dev/null and b/assets/Sounds/Jelly/gore - flesh guts gore impact blood squirt wet - hard - 49.wav differ diff --git a/assets/Sounds/Jelly/gore - flesh guts gore movements wet - 22.wav b/assets/Sounds/Jelly/gore - flesh guts gore movements wet - 22.wav new file mode 100644 index 0000000..8026e6b Binary files /dev/null and b/assets/Sounds/Jelly/gore - flesh guts gore movements wet - 22.wav differ diff --git a/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - medium - 11.wav b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - medium - 11.wav new file mode 100644 index 0000000..a2e4cc9 Binary files /dev/null and b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - medium - 11.wav differ diff --git a/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 14.wav b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 14.wav new file mode 100644 index 0000000..d7826c9 Binary files /dev/null and b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 14.wav differ diff --git a/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 4.wav b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 4.wav new file mode 100644 index 0000000..d89fc3c Binary files /dev/null and b/assets/Sounds/Jelly/gore - wood beating flesh wet blood splat - soft - 4.wav differ diff --git a/assets/Sounds/Metal/EFX EXT Metal Impact Smash Move 07 B.M.wav b/assets/Sounds/Metal/EFX EXT Metal Impact Smash Move 07 B.M.wav new file mode 100644 index 0000000..f68bc16 Binary files /dev/null and b/assets/Sounds/Metal/EFX EXT Metal Impact Smash Move 07 B.M.wav differ diff --git a/assets/Sounds/Metal/EFX SD Metal plate bang 01 B.M.wav b/assets/Sounds/Metal/EFX SD Metal plate bang 01 B.M.wav new file mode 100644 index 0000000..65c981c Binary files /dev/null and b/assets/Sounds/Metal/EFX SD Metal plate bang 01 B.M.wav differ diff --git a/assets/Sounds/Metal/IMPACT Metal Blade Clang 01.wav b/assets/Sounds/Metal/IMPACT Metal Blade Clang 01.wav new file mode 100644 index 0000000..04a8f2f Binary files /dev/null and b/assets/Sounds/Metal/IMPACT Metal Blade Clang 01.wav differ diff --git a/assets/Sounds/Metal/Metal Case Detuned Boing Spring_VS 06.wav b/assets/Sounds/Metal/Metal Case Detuned Boing Spring_VS 06.wav new file mode 100644 index 0000000..a25a601 Binary files /dev/null and b/assets/Sounds/Metal/Metal Case Detuned Boing Spring_VS 06.wav differ diff --git a/assets/Sounds/Metal/Metal Shelf Hit 10.wav b/assets/Sounds/Metal/Metal Shelf Hit 10.wav new file mode 100644 index 0000000..537bb6c Binary files /dev/null and b/assets/Sounds/Metal/Metal Shelf Hit 10.wav differ diff --git a/assets/Sounds/Metal/Timpani_Hit_Fienup_001.wav b/assets/Sounds/Metal/Timpani_Hit_Fienup_001.wav new file mode 100644 index 0000000..14b089e Binary files /dev/null and b/assets/Sounds/Metal/Timpani_Hit_Fienup_001.wav differ diff --git a/assets/Sounds/Metal/impact-bak1.wav b/assets/Sounds/Metal/impact-bak1.wav new file mode 100644 index 0000000..04a8f2f Binary files /dev/null and b/assets/Sounds/Metal/impact-bak1.wav differ diff --git a/assets/Sounds/Metal/impact.wav b/assets/Sounds/Metal/impact.wav new file mode 100644 index 0000000..5a08fc7 Binary files /dev/null and b/assets/Sounds/Metal/impact.wav differ diff --git a/assets/Sounds/Two week old Baby 01.wav b/assets/Sounds/Two week old Baby 01.wav new file mode 100644 index 0000000..c5b1594 Binary files /dev/null and b/assets/Sounds/Two week old Baby 01.wav differ diff --git a/assets/Sounds/Water/Helfenberger_Grund_02.wav b/assets/Sounds/Water/Helfenberger_Grund_02.wav new file mode 100644 index 0000000..f82087e Binary files /dev/null and b/assets/Sounds/Water/Helfenberger_Grund_02.wav differ diff --git a/assets/Sounds/Water/River_heavy_dripping_from_wall_of_rocks.wav b/assets/Sounds/Water/River_heavy_dripping_from_wall_of_rocks.wav new file mode 100644 index 0000000..e8c37b9 Binary files /dev/null and b/assets/Sounds/Water/River_heavy_dripping_from_wall_of_rocks.wav differ diff --git a/assets/Sounds/Water/Roeder_Pearls_01.wav b/assets/Sounds/Water/Roeder_Pearls_01.wav new file mode 100644 index 0000000..3ee4c5c Binary files /dev/null and b/assets/Sounds/Water/Roeder_Pearls_01.wav differ diff --git a/assets/Sounds/Water/WATER Bubbles 02.wav b/assets/Sounds/Water/WATER Bubbles 02.wav new file mode 100644 index 0000000..bf83c99 Binary files /dev/null and b/assets/Sounds/Water/WATER Bubbles 02.wav differ diff --git a/assets/Sounds/Water/Water_Fountain_Fienup_002.wav b/assets/Sounds/Water/Water_Fountain_Fienup_002.wav new file mode 100644 index 0000000..c09933c Binary files /dev/null and b/assets/Sounds/Water/Water_Fountain_Fienup_002.wav differ diff --git a/assets/Sounds/Water/Water_Splash_SeaLion_Fienup_001.wav b/assets/Sounds/Water/Water_Splash_SeaLion_Fienup_001.wav new file mode 100644 index 0000000..767c055 Binary files /dev/null and b/assets/Sounds/Water/Water_Splash_SeaLion_Fienup_001.wav differ diff --git a/include/Core/Util/EPlaySound.h b/include/Core/EPlaySFX.h similarity index 80% rename from include/Core/Util/EPlaySound.h rename to include/Core/EPlaySFX.h index 7cf0d32..2d038f7 100644 --- a/include/Core/Util/EPlaySound.h +++ b/include/Core/EPlaySFX.h @@ -1,23 +1,23 @@ /* This file is part of Daydream Engine. Copyright 2014 Adam Byléhn, Tobias Dahl, Simon Holmberg, Viktor Ljung - + Daydream Engine is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + Daydream Engine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - + You should have received a copy of the GNU Lesser General Public License along with Daydream Engine. If not, see . */ -#ifndef DAYDREAM_EPLAYSOUND_H -#define DAYDREAM_EPLAYSOUND_H +#ifndef Events_PlaySFX_h__ +#define Events_PlaySFX_h__ #include "Core/EventBroker.h" @@ -27,14 +27,13 @@ namespace dd namespace Events { -struct PlaySound : Event +struct PlaySFX : Event { - float volume; - std::string path; + std::string path; }; } } -#endif //DAYDREAM_EPLAYSOUND_H +#endif // Events_PlaySFX_h__ \ No newline at end of file diff --git a/include/Core/EPlaySound.h b/include/Core/EPlaySound.h deleted file mode 100644 index 2ce52d8..0000000 --- a/include/Core/EPlaySound.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Created by Adam on 2015-09-09. -// - -#ifndef DAYDREAM_EPLAYSOUND_H -#define DAYDREAM_EPLAYSOUND_H - -#include -#include "EventBroker.h" - - -namespace dd -{ - -namespace Events -{ - -struct PlaySound -{ - std::string path; -}; - -} - -} - -#endif //DAYDREAM_EPLAYSOUND_H diff --git a/include/Core/Sound.h b/include/Core/Sound.h index 6639147..66c6348 100644 --- a/include/Core/Sound.h +++ b/include/Core/Sound.h @@ -25,7 +25,8 @@ #include "Core/System.h" #include "Core/World.h" #include "Core/EKeyDown.h" -#include "Core/EPlaySound.h" +#include "Core/EPlaySFX.h" +#include "Physics/EContact.h" #include "Core/EventBroker.h" namespace dd @@ -53,10 +54,12 @@ public: private: //Events dd::EventRelay m_EKeyDown; - bool OnKeyDown(const dd::Events::KeyDown &event); + dd::EventRelay m_EPlaySFX; + dd::EventRelay m_EContact; - //dd::EventRelay m_EPlaySound; - //bool PlayASound(const dd::Events::PlaySound &event); + bool OnKeyDown(const dd::Events::KeyDown &event); + bool OnPlaySFX(const dd::Events::PlaySFX &event); + bool OnContact(const dd::Events::Contact &event); ALuint LoadFile(std::string fileName); ALuint CreateSource(); diff --git a/src/game/Core/Sound.cpp b/src/game/Core/Sound.cpp index d191452..f5b3023 100644 --- a/src/game/Core/Sound.cpp +++ b/src/game/Core/Sound.cpp @@ -16,6 +16,9 @@ along with Daydream Engine. If not, see . */ +#include +#include +#include #include "PrecompiledHeader.h" #include "Core/Sound.h" @@ -42,8 +45,9 @@ void dd::Systems::Sound::Initialize() alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); //Subscribe to events + EVENT_SUBSCRIBE_MEMBER(m_EContact, &Sound::OnContact); EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Sound::OnKeyDown); - //EVENT_SUBSCRIBE_MEMBER(m_EPlaySound, &Sound::PlayASound); + EVENT_SUBSCRIBE_MEMBER(m_EPlaySFX, &Sound::OnPlaySFX); } void dd::Systems::Sound::Update(double dt) @@ -54,25 +58,67 @@ void dd::Systems::Sound::Update(double dt) alSourcefv(m_Source, AL_POSITION, pos); } -/*bool dd::Systems::Sound::PlayASound(const dd::Events::PlaySound &event) +bool dd::Systems::Sound::OnPlaySFX(const dd::Events::PlaySFX &event) { + m_Source = CreateSource(); + ALuint buffer = LoadFile(event.path); -}*/ + alSourcei(m_Source, AL_BUFFER, buffer); + alSourcePlay(m_Source); +} bool dd::Systems::Sound::OnKeyDown(const dd::Events::KeyDown &event) { // #define GLFW_KEY_S 83 /*if (event.KeyCode == 83) { - Events::PlaySound e; - e.path = "Sounds/screwed.wav"; - EventBroker->Publish(e); + }*/ if (event.KeyCode == 83) { - m_Source = CreateSource(); - ALuint buffer = LoadFile("Sounds/screwed.wav"); - alSourcei(m_Source, AL_BUFFER, buffer); - alSourcePlay(m_Source); + } +} + +bool dd::Systems::Sound::OnContact(const dd::Events::Contact &event) +{ + int localBallEntID = 0; + //Make sure a ball is colliding + auto ball = m_World->GetComponent(event.Entity1); + if (ball == NULL) { + ball = m_World->GetComponent(event.Entity2); + if (ball == NULL) { + return false; + } + else { + localBallEntID = 2; + } + } + else { + localBallEntID = 1; + } + + //Determine which event.Entity is not t + EntityID collObject; + if (localBallEntID == 1) { + collObject = event.Entity2; + } + else if (localBallEntID == 2) { + collObject = event.Entity1; + } + + /*auto collisionBrick = m_World->GetComponent(collObject); + if (collisionBrick != NULL) { + dd::Events::PlaySFX e; + e.path = "Sounds/Brick/brickBreak.wav"; + EventBroker->Publish(e); + return true; + }*/ + + auto collisionPad = m_World->GetComponent(collObject); + if (collisionPad != NULL) { + dd::Events::PlaySFX e; + e.path = "Sounds/Metal/impact.wav"; + EventBroker->Publish(e); + return true; } }