diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2019-10-03 10:24:01 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2019-10-03 10:24:01 -0400 |
commit | eed19ec73698c8180a51c33fa56c7cfe7c0e60f0 (patch) | |
tree | d231c15d73a16decf0c76b399bb2e212507ad195 | |
parent | 16a29df61f6cbc546123c91a0b72d1bfb68d6de2 (diff) |
positional audio working
-rw-r--r-- | Assets/boing.wav | bin | 605018 -> 302628 bytes | |||
-rw-r--r-- | Assets/jump.wav | bin | 303194 -> 151716 bytes | |||
-rw-r--r-- | src/audio.cpp | 18 | ||||
-rw-r--r-- | src/engine.cpp | 1 |
4 files changed, 17 insertions, 2 deletions
diff --git a/Assets/boing.wav b/Assets/boing.wav Binary files differindex a142197..088963d 100644 --- a/Assets/boing.wav +++ b/Assets/boing.wav diff --git a/Assets/jump.wav b/Assets/jump.wav Binary files differindex 1cd1681..b9849ab 100644 --- a/Assets/jump.wav +++ b/Assets/jump.wav 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 <AL/alut.h> #include <iostream> @@ -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<Player, Position>( + []([[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<Audio>& cae) { diff --git a/src/engine.cpp b/src/engine.cpp index c6bec27..dc0c481 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -120,6 +120,7 @@ void Engine::logicLoop(void) }); } + systems.update<AudioSystem>(dt); std::this_thread::yield(); } } |