fixed a bug in my last effects removal, improved the algo to determine if a badguy...
[supertux.git] / src / sector.cpp
index 657996f..aeb4530 100644 (file)
@@ -16,7 +16,6 @@
 //  You should have received a copy of the GNU General Public License
 //  along with this program; if not, write to the Free Software
 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
-
 #include <config.h>
 
 #include <memory>
 #include "object/block.h"
 #include "object/invisible_block.h"
 #include "object/bullet.h"
+#include "object/text_object.h"
 #include "badguy/jumpy.h"
 #include "badguy/spike.h"
 #include "trigger/sequence_trigger.h"
 #include "player_status.h"
 #include "scripting/script_interpreter.h"
+#include "scripting/sound.h"
+#include "scripting/scripted_object.h"
+#include "scripting/text.h"
 
 //#define USE_GRID
 
@@ -424,6 +427,28 @@ Sector::activate(const std::string& spawnpoint)
       delete interpreter;
       interpreter = 0;
       interpreter = new ScriptInterpreter();
+
+      // expose ScriptedObjects to the script
+      for(GameObjects::iterator i = gameobjects.begin();
+          i != gameobjects.end(); ++i) {
+        GameObject* object = *i;
+        Scripting::ScriptedObject* scripted_object
+          = dynamic_cast<Scripting::ScriptedObject*> (object);
+        if(!scripted_object)
+          continue;
+
+        std::cout << "Exposing " << scripted_object->get_name() << "\n";
+        interpreter->expose_object(scripted_object,
+                                   scripted_object->get_name(),
+                                   "ScriptedObject");
+      }
+      Scripting::Sound* sound = new Scripting::Sound();
+      interpreter->expose_object(sound, "Sound", "Sound");
+      TextObject* text_object = new TextObject();
+      add_object(text_object);
+      Scripting::Text* text = static_cast<Scripting::Text*> (text_object);
+      interpreter->expose_object(text, "Text", "Text");
+
       std::string sourcename = std::string("Sector(") + name + ") - init";
       std::istringstream in(init_script);
       printf("Load script.\n");
@@ -456,6 +481,9 @@ Sector::get_active_region()
 void
 Sector::action(float elapsed_time)
 {
+  if(interpreter)
+    interpreter->update();
+  
   player->check_bounds(camera);
 
 #if 0