From af39f2e08b0503db723ae707a5c7278d8c85f812 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 1 Oct 2019 20:50:28 -0400 Subject: Audio component loading, getting ready to play --- Assets/jump.wav | Bin 0 -> 303194 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Assets/jump.wav (limited to 'Assets') diff --git a/Assets/jump.wav b/Assets/jump.wav new file mode 100644 index 0000000..1cd1681 Binary files /dev/null and b/Assets/jump.wav differ -- cgit v1.2.3 From 16a29df61f6cbc546123c91a0b72d1bfb68d6de2 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 2 Oct 2019 13:51:26 -0400 Subject: beautiful ball bounce sound --- Assets/boing.wav | Bin 0 -> 605018 bytes Scripts/init.lua | 4 ++++ 2 files changed, 4 insertions(+) create mode 100644 Assets/boing.wav (limited to 'Assets') diff --git a/Assets/boing.wav b/Assets/boing.wav new file mode 100644 index 0000000..a142197 Binary files /dev/null and b/Assets/boing.wav differ diff --git a/Scripts/init.lua b/Scripts/init.lua index d09fb14..96e031a 100644 --- a/Scripts/init.lua +++ b/Scripts/init.lua @@ -80,10 +80,14 @@ ball = { }, Idle = function(self) if self.Physics.standing == true then + game.play(self.Position, self.Audio) self.Velocity.y = self.Velocity.y + 15 self.Velocity.x = math.random(-1, 1); end end, + Audio = { + file = "Assets/boing.wav" + }, } -- Create the world -- cgit v1.2.3 From eed19ec73698c8180a51c33fa56c7cfe7c0e60f0 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 3 Oct 2019 10:24:01 -0400 Subject: positional audio working --- Assets/boing.wav | Bin 605018 -> 302628 bytes Assets/jump.wav | Bin 303194 -> 151716 bytes src/audio.cpp | 18 ++++++++++++++++-- src/engine.cpp | 1 + 4 files changed, 17 insertions(+), 2 deletions(-) (limited to 'Assets') diff --git a/Assets/boing.wav b/Assets/boing.wav index a142197..088963d 100644 Binary files a/Assets/boing.wav and b/Assets/boing.wav differ diff --git a/Assets/jump.wav b/Assets/jump.wav index 1cd1681..b9849ab 100644 Binary files a/Assets/jump.wav and b/Assets/jump.wav differ diff --git a/src/audio.cpp b/src/audio.cpp index 8bb1413..2f14c97 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -19,6 +19,7 @@ */ #include "audio.hpp" +#include "components/Player.hpp" #include #include @@ -55,12 +56,25 @@ void AudioSystem::configure([[maybe_unused]] entityx::EntityManager& entities, if (alutInitWithoutContext(nullptr, nullptr) != AL_TRUE) return; // TODO Third uh oh + + ALfloat listenerOri[] = { 0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f }; + alListener3f(AL_POSITION, 0, 0, 0.0f); + alListener3f(AL_VELOCITY, 0, 0, 0); + alListenerfv(AL_ORIENTATION, listenerOri); } -void AudioSystem::update([[maybe_unused]] entityx::EntityManager& entities, +void AudioSystem::update(entityx::EntityManager& entities, [[maybe_unused]] entityx::EventManager& events, [[maybe_unused]] entityx::TimeDelta dt) -{} +{ + entities.each( + []([[maybe_unused]] entityx::Entity e, + [[maybe_unused]] Player& p, + Position &pos) + { + alListener3f(AL_POSITION, pos.x, pos.y, 0.0f); + }); +} void AudioSystem::receive(const entityx::ComponentAddedEvent