From: Christoph Sommer Date: Sun, 6 Jan 2008 02:52:24 +0000 (+0000) Subject: Play stereo effects in relation to camera, not player (closes issue 56) X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=d0d05bbf22ee54ca293254a02901e395622974b4;p=supertux.git Play stereo effects in relation to camera, not player (closes issue 56) SVN-Revision: 5258 --- diff --git a/src/game_session.cpp b/src/game_session.cpp index a0e48c394..e918a0975 100644 --- a/src/game_session.cpp +++ b/src/game_session.cpp @@ -528,7 +528,7 @@ GameSession::update(float elapsed_time) } // update sounds - sound_manager->set_listener_position(currentsector->player->get_pos()); + if (currentsector && currentsector->camera) sound_manager->set_listener_position(currentsector->camera->get_center()); /* Handle music: */ if (end_sequence) diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index 5d3a7929d..14df03828 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -32,6 +32,7 @@ #include "audio/sound_source.hpp" #include "log.hpp" #include "scripting/squirrel_util.hpp" +#include "object/camera.hpp" AmbientSound::AmbientSound(const lisp::Lisp& lisp) { @@ -83,6 +84,7 @@ AmbientSound::AmbientSound(const lisp::Lisp& lisp) lisp.get("silence_distance",silence_distance); sound_source = 0; // not playing at the beginning + sound_manager->preload(sample); latency=0; } @@ -152,9 +154,10 @@ AmbientSound::update(float deltat) float px,py; float rx,ry; - // Player position - px=Sector::current()->player->get_pos().x; - py=Sector::current()->player->get_pos().y; + if (!Sector::current() || !Sector::current()->camera) return; + // Camera position + px=Sector::current()->camera->get_center().x; + py=Sector::current()->camera->get_center().y; // Relate to which point in the area rx=px