Silence compiler warning
[supertux.git] / src / object / scripted_object.cpp
index 8f1ab36..b5ae6ed 100644 (file)
 #include "scripting/squirrel_util.hpp"
 #include "sprite/sprite.hpp"
 #include "supertux/object_factory.hpp"
-
-ScriptedObject::ScriptedObject(const Reader& lisp)
-  : MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC),
-    solid(true), physic_enabled(true), visible(true), new_vel_set(false)
+#include "util/reader.hpp"
+
+ScriptedObject::ScriptedObject(const Reader& lisp) :
+  MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC),
+  physic(),
+  name(),
+  solid(true),
+  physic_enabled(true),
+  visible(true),
+  new_vel_set(false),
+  new_vel()
 {
   lisp.get("name", name);
   if(name == "")
@@ -40,7 +47,7 @@ ScriptedObject::ScriptedObject(const Reader& lisp)
   lisp.get("solid", solid);
   lisp.get("physic-enabled", physic_enabled);
   lisp.get("visible", visible);
-  lisp.get("z-pos", layer);
+  layer = reader_get_layer (lisp, /* default = */ LAYER_OBJECTS);
   if( solid ){
     set_group( COLGROUP_MOVING_STATIC );
   } else {
@@ -52,14 +59,14 @@ void
 ScriptedObject::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  expose_object(vm, table_idx, dynamic_cast<Scripting::ScriptedObject *>(this), name, false);
+  expose_object(vm, table_idx, dynamic_cast<scripting::ScriptedObject *>(this), name, false);
 }
 
 void
 ScriptedObject::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  Scripting::unexpose_object(vm, table_idx, name);
+  scripting::unexpose_object(vm, table_idx, name);
 }
 
 void
@@ -71,8 +78,8 @@ ScriptedObject::move(float x, float y)
 void
 ScriptedObject::set_pos(float x, float y)
 {
-  printf("SetPos: %f %f\n", x, y);
-  bbox.set_pos(Vector(x, y));
+  // printf("SetPos: %f %f\n", x, y);
+  MovingObject::set_pos(Vector(x, y));
   physic.reset();
 }
 
@@ -108,9 +115,9 @@ ScriptedObject::get_velocity_y()
 }
 
 void
-ScriptedObject::set_visible(bool visible)
+ScriptedObject::set_visible(bool visible_)
 {
-  this->visible = visible;
+  this->visible = visible_;
 }
 
 bool
@@ -120,9 +127,9 @@ ScriptedObject::is_visible()
 }
 
 void
-ScriptedObject::set_solid(bool solid)
+ScriptedObject::set_solid(bool solid_)
 {
-  this->solid = solid;
+  this->solid = solid_;
   if( solid ){
     set_group( COLGROUP_MOVING_STATIC );
   } else {
@@ -136,6 +143,18 @@ ScriptedObject::is_solid()
   return solid;
 }
 
+bool
+ScriptedObject::gravity_enabled() const
+{
+       return physic.gravity_enabled();
+}
+
+void
+ScriptedObject::enable_gravity(bool f)
+{
+       physic.enable_gravity(f);
+}
+
 void
 ScriptedObject::set_action(const std::string& animation)
 {
@@ -200,6 +219,4 @@ ScriptedObject::collision(GameObject& , const CollisionHit& )
   return FORCE_MOVE;
 }
 
-IMPLEMENT_FACTORY(ScriptedObject, "scriptedobject");
-
 /* EOF */