Fixed ambient sound scripting
[supertux.git] / src / object / ambient_sound.cpp
index 1287391..8fad2a9 100644 (file)
 #include "audio/sound_manager.hpp"
 #include "audio/sound_source.hpp"
 #include "log.hpp"
+#include "scripting/squirrel_util.hpp"
 
 AmbientSound::AmbientSound(const lisp::Lisp& lisp)
 {
+  name="";
   position.x = 0;
   position.y = 0;
 
@@ -49,6 +51,7 @@ AmbientSound::AmbientSound(const lisp::Lisp& lisp)
     log_warning << "No Position in ambient_sound" << std::endl;
   }
 
+  lisp.get("name" , name);
   lisp.get("width" , dimension.x);
   lisp.get("height", dimension.y);
 
@@ -197,10 +200,6 @@ AmbientSound::update(float deltat)
 
   //  if (latency>0.001/distance_factor)
   // latency=
-  
-  if( sound_source != NULL ){
-      sound_source->update();
-  }
 }
 
 void
@@ -208,4 +207,33 @@ AmbientSound::draw(DrawingContext &)
 {
 }
 
+void
+AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx)
+{
+  Scripting::AmbientSound* interface = static_cast<Scripting::AmbientSound*> (this);
+  expose_object(vm, table_idx, interface, name, false);
+}
+
+void
+AmbientSound::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
+{
+  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");