* The "time needed" statistic now works again. You might need to delete your savegame...
[supertux.git] / src / object / rock.cpp
index 7c010a2..b6ad844 100644 (file)
 //  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 "rock.h"
-#include "sprite/sprite.h"
-#include "sprite/sprite_manager.h"
-#include "lisp/writer.h"
-#include "video/drawing_context.h"
-#include "resources.h"
-#include "object_factory.h"
+#include "rock.hpp"
+#include "sprite/sprite.hpp"
+#include "sprite/sprite_manager.hpp"
+#include "lisp/writer.hpp"
+#include "video/drawing_context.hpp"
+#include "resources.hpp"
+#include "object_factory.hpp"
 
 Rock::Rock(const lisp::Lisp& reader)
 {
@@ -57,7 +56,6 @@ Rock::write(lisp::Writer& writer)
 void
 Rock::draw(DrawingContext& context)
 {
-
   sprite->draw(context, get_pos(), LAYER_OBJECTS);
 }
 
@@ -66,33 +64,38 @@ Rock::update(float elapsed_time)
 {
   if(!grabbed) {
     flags |= FLAG_SOLID;
-    flags &= ~FLAG_NO_COLLDET;
+    set_group(COLGROUP_MOVING);
     movement = physic.get_movement(elapsed_time);
   } else {
     physic.set_velocity(0, 0);
     flags &= ~FLAG_SOLID;
-    flags |= FLAG_NO_COLLDET;
+    set_group(COLGROUP_DISABLED);
   }
   
   grabbed = false;
 }
 
 HitResponse
-Rock::collision(GameObject& , const CollisionHit& )
+Rock::collision(GameObject& object, const CollisionHit& )
 {
-  if(grabbed)
+  if(grabbed) {
     return FORCE_MOVE;
+  }
+
+  if(object.get_flags() & FLAG_SOLID) {
+    physic.set_velocity(0, 0);
+    return CONTINUE;
+  }
 
-  physic.set_velocity(0, 0);
-  return CONTINUE;
+  return FORCE_MOVE;
 }
 
 void
-Rock::grab(MovingObject& , const Vector& pos)
+Rock::grab(MovingObject& , const Vector& pos, Direction)
 {
   movement = pos - get_pos();
   grabbed = true;
 }
 
-IMPLEMENT_FACTORY(Rock, "rock")
+IMPLEMENT_FACTORY(Rock, "rock");