More -Weffc++ cleanup
[supertux.git] / src / object / scripted_object.cpp
index 65dffb4..b1a572a 100644 (file)
@@ -1,12 +1,10 @@
-//  $Id$
-//
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
-//  This program is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU General Public License
-//  as published by the Free Software Foundation; either version 2
-//  of the License, or (at your option) any later version.
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
 //
 //  This program is distributed in the hope that it will be useful,
 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
 //  GNU General Public License for more details.
 //
 //  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>
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "object/scripted_object.hpp"
 
-#include <stdexcept>
-#include <math.h>
+#include <stdio.h>
 
-#include "scripted_object.hpp"
-#include "video/drawing_context.hpp"
 #include "scripting/squirrel_util.hpp"
-#include "resources.hpp"
-#include "object_factory.hpp"
-#include "math/vector.hpp"
+#include "sprite/sprite.hpp"
+#include "supertux/object_factory.hpp"
 
-ScriptedObject::ScriptedObject(const lisp::Lisp& lisp)
-  : MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING),
-    solid(true), physic_enabled(true), visible(true), new_vel_set(false)
+ScriptedObject::ScriptedObject(const Reader& lisp) :
+  MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC),
+  solid(true), 
+  physic_enabled(true), 
+  visible(true), 
+  new_vel_set(false)
 {
   lisp.get("name", name);
   if(name == "")
@@ -48,11 +45,7 @@ ScriptedObject::ScriptedObject(const lisp::Lisp& lisp)
   lisp.get("visible", visible);
   lisp.get("z-pos", layer);
   if( solid ){
-    if( physic_enabled ){
-      set_group( COLGROUP_MOVING );
-    } else {
-      set_group( COLGROUP_STATIC );
-    }
+    set_group( COLGROUP_MOVING_STATIC );
   } else {
     set_group( COLGROUP_DISABLED );
   }
@@ -134,11 +127,7 @@ ScriptedObject::set_solid(bool solid)
 {
   this->solid = solid;
   if( solid ){
-    if( physic_enabled ){
-      set_group( COLGROUP_MOVING );
-    } else {
-      set_group( COLGROUP_STATIC );
-    }
+    set_group( COLGROUP_MOVING_STATIC );
   } else {
     set_group( COLGROUP_DISABLED );
   }
@@ -150,7 +139,6 @@ ScriptedObject::is_solid()
   return solid;
 }
 
-
 void
 ScriptedObject::set_action(const std::string& animation)
 {
@@ -201,7 +189,7 @@ ScriptedObject::collision_solid(const CollisionHit& hit)
     if(physic.get_velocity_y() > 0)
       physic.set_velocity_y(0);
   } else if(hit.top) {
-    physic.set_velocity_y(.1);
+    physic.set_velocity_y(.1f);
   }
 
   if(hit.left || hit.right) {
@@ -216,3 +204,5 @@ ScriptedObject::collision(GameObject& , const CollisionHit& )
 }
 
 IMPLEMENT_FACTORY(ScriptedObject, "scriptedobject");
+
+/* EOF */