- virtual void collision(const MovingObject& other_object,
- int collision_type) = 0;
-
- Vector get_pos() const
- { return Vector(base.x, base.y); }
-
- base_type base;
- base_type old_base;
-
-protected:
-#if 0 // this will be used in my collision detection rewrite later
- /// the current position of the object
- Vector pos;
- /// the position we want to move until next frame
- Vector new_pos;
- /// the bounding box relative to the current position
- Rectangle bounding_box;
-#endif
-};
+ class MovingObject : public GameObject
+ {
+ public:
+ MovingObject();
+ virtual ~MovingObject();
+
+ /** this function is called when the object collided with any other object
+ */
+ virtual HitResponse collision(GameObject& other,
+ const CollisionHit& hit) = 0;
+
+ const Vector& get_pos() const
+ {
+ return bbox.p1;
+ }
+
+ /** returns the bounding box of the Object */
+ const Rectangle& get_bbox() const
+ {
+ return bbox;
+ }
+
+ const Vector& get_movement() const
+ {
+ return movement;
+ }
+
+ protected:
+ friend class Sector;
+ friend class CollisionGrid;
+
+ /** The bounding box of the object (as used for collision detection, this
+ * isn't necessarily the bounding box for graphics)
+ */
+ Rectangle bbox;
+ /** The movement that will happen till next frame
+ */
+ Vector movement;
+ };
+
+} //namespace SuperTux