From: Wolfgang Becker Date: Wed, 5 Jul 2006 10:40:36 +0000 (+0000) Subject: Fixed ambient sound scripting X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e66a5fa8d047b05f784ee4f595d8895eff129fc3;p=supertux.git Fixed ambient sound scripting SVN-Revision: 3890 --- diff --git a/data/levels/world2/village.stl b/data/levels/world2/village.stl index 9cc19fab4..fd3de2d20 100644 --- a/data/levels/world2/village.stl +++ b/data/levels/world2/village.stl @@ -287,6 +287,15 @@ (x 1076) (y 884) ) + (scripttrigger + (script "//move saw to start +tischsaege.goto_node( 0 ) ") + (button #f) + (width 32) + (height 124) + (x 1088) + (y 416) + ) (secretarea (width 569.4012) (height 312.0143) diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index 5ac3b0fbe..8fad2a9c5 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -30,7 +30,6 @@ #include "audio/sound_manager.hpp" #include "audio/sound_source.hpp" #include "log.hpp" -#include "scripting/ambient_sound.hpp" #include "scripting/squirrel_util.hpp" AmbientSound::AmbientSound(const lisp::Lisp& lisp) @@ -211,16 +210,30 @@ AmbientSound::draw(DrawingContext &) void AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx) { - if (name == "") return; - Scripting::AmbientSound* interface = new Scripting::AmbientSound(this); - expose_object(vm, table_idx, interface, name, true); + Scripting::AmbientSound* interface = static_cast (this); + expose_object(vm, table_idx, interface, name, false); } void AmbientSound::unexpose(HSQUIRRELVM vm, SQInteger table_idx) { - if (name == "") return; Scripting::unexpose_object(vm, table_idx, name); } +void +AmbientSound::set_pos(float x, float y){ + position.x = x; + position.y = y; +} + +float +AmbientSound::get_pos_x(){; + return position.x; +} + +float +AmbientSound::get_pos_y(){ + return position.y; +} + IMPLEMENT_FACTORY(AmbientSound, "ambient_sound"); diff --git a/src/object/ambient_sound.hpp b/src/object/ambient_sound.hpp index 74d9c9d32..2a587880e 100644 --- a/src/object/ambient_sound.hpp +++ b/src/object/ambient_sound.hpp @@ -47,16 +47,17 @@ #include "resources.hpp" #include "player.hpp" #include "script_interface.hpp" +#include "scripting/ambient_sound.hpp" class SoundSource; -class AmbientSound : public GameObject, public ScriptInterface +class AmbientSound : public GameObject, public ScriptInterface, public Scripting::AmbientSound { public: AmbientSound(const lisp::Lisp& lisp); AmbientSound(Vector pos, float factor, float bias, float vol, std::string file); ~AmbientSound(); - + void set_pos(Vector newpos) { position=newpos; @@ -65,6 +66,13 @@ public: { return position; } + + // --- Scripting Interface --- + + void set_pos(float x, float y); + float get_pos_x(); + float get_pos_y(); + protected: virtual void hit(Player& player); virtual void update(float time); diff --git a/src/scripting/ambient_sound.hpp b/src/scripting/ambient_sound.hpp new file mode 100644 index 000000000..2cff32c5d --- /dev/null +++ b/src/scripting/ambient_sound.hpp @@ -0,0 +1,23 @@ +#ifndef __SCRIPTING_AMBIENT_SOUND_H__ +#define __SCRIPTING_AMBIENT_SOUND_H__ + +namespace Scripting +{ + +class AmbientSound +{ +public: +#ifndef SCRIPTING_API + virtual ~AmbientSound() + {} +#endif + + virtual void set_pos(float x, float y) = 0; + virtual float get_pos_x() = 0; + virtual float get_pos_y() = 0; +}; + +} + +#endif +