added a missing include line.
[supertux.git] / src / moving_object.hpp
index b23302a..69d36a3 100644 (file)
@@ -31,7 +31,7 @@ class CollisionGrid;
 
 enum CollisionGroup {
   /** Objects in DISABLED group are not tested for collisions */
-  COLGROUP_DISABLED,
+  COLGROUP_DISABLED = 0,
   /**
    * "default" is moving object. MovingObjects get tested against all other
    * objects and against other movingobjects
@@ -42,6 +42,8 @@ enum CollisionGroup {
    * MovingOnlyStatic objects), but is tested against all other objects.
    */
   COLGROUP_MOVING_ONLY_STATIC,
+  /** TODO write docu :-/ */
+  COLGROUP_MOVING_STATIC,
   /**
    * Doesn't move and isn't explicitely checked for collisions with other
    * objects (but other objects might check with this)
@@ -77,8 +79,7 @@ enum CollisionGroup {
 class MovingObject : public GameObject
 {
 public:
-  MovingObject(std::string name = "");
-  MovingObject(const lisp::Lisp& lisp);
+  MovingObject();
   virtual ~MovingObject();
 
   /** this function is called when the object collided with something solid */
@@ -86,6 +87,16 @@ public:
   {
     (void) hit;
   }
+  /**
+   * when 2 objects collided, we will first call the pre_collision_check
+   * functions of both objects that can decide on how to react to the collision.
+   */
+  virtual bool collides(GameObject& other, const CollisionHit& hit)
+  {
+    (void) other;
+    (void) hit;
+    return true;
+  }
   /** this function is called when the object collided with any other object */
   virtual HitResponse collision(GameObject& other, const CollisionHit& hit) = 0;
   /** called when tiles with special attributes have been touched */
@@ -136,80 +147,27 @@ public:
    * using this function. There are no collision detection checks performed
    * here so bad things could happen.
    */
-  /*virtual void set_size(float w, float h)
+  virtual void set_size(float w, float h)
   {
     dest.set_size(w, h);
     bbox.set_size(w, h);
-  }*/
+  }
 
   CollisionGroup get_group() const
   {
     return group;
   }
 
-  void set_group(CollisionGroup group)
-  {
-    this->group = group;
-  }
-
-  // --- BEGIN METHODS TO EXPOSE TO SQUIRREL --- //
-  void set_solid(bool solid)
-  {
-    this->solid = solid;
-  }
-  bool is_solid() const
-  {
-    return solid;
-  }
-  void move(float x, float y)
-  {
-    bbox.move(Vector(x, y));
-  }
-  void set_pos(float x, float y)
-  {
-    set_pos(Vector(x, y));
-  }
-  float get_pos_x() const
-  {
-    return bbox.get_left();
-  }
-  float get_pos_y() const
-  {
-    return bbox.get_top();
-  }
-  void set_size(float w, float h)
-  {
-    dest.set_size(w, h);
-    bbox.set_size(w, h);
-  }
-  float get_width() const
-  {
-    return bbox.get_width();
-  }
-  float get_height() const
-  {
-    return bbox.get_height();
-  }
-  void set_velocity(float x, float y)
-  {
-    movement = Vector(x, y);
-  }
-  float get_velocity_x() const
-  {
-    return movement.x;
-  }
-  float get_velocity_y() const
-  {
-    return movement.y;
-  }
-  // --- END METHODS TO EXPOSE TO SQUIRREL --- //
-
 protected:
-  MovingObject(Rect bbox, CollisionGroup group, bool solid);
   friend class Sector;
   friend class CollisionGrid;
   friend class Platform;
 
+  void set_group(CollisionGroup group)
+  {
+    this->group = group;
+  }
+
   /** The bounding box of the object (as used for collision detection, this
    * isn't necessarily the bounding box for graphics)
    */
@@ -229,8 +187,6 @@ private:
    * during collision detection
    */
   Rect dest;
-
-  bool solid; /**< true if this object should be considered when doing collision detection */
 };
 
 #endif