#ifndef __BOUNDEDOBJECT_H__ #define __BOUNDEDOBJECT_H__ #include "object.h" // BoundedObject is an abstract class that defines a bounding // box for objects. A bounding box is defined as class BoundedObject : public InteractableObject { public: // Calculate the bounding box of an object. Note that // a bounding box is defined as a box that covers all of // the primitives in the drawing list. Also note that // this method should be called whenever you modify the // contents of the draw list; otherwise, the bounding // box might not accurately portray the changes you've made. virtual void calculateBounds(); // Determine whether or not two bounded objects are // intersecting with each other. Because we use the // bounding box as our guide, detection is not 100% // accurate. virtual bool intersects(const BoundedObject& other) const; // We've overriden the intersects method, so we need // to allow access to the superclass intersects method // as well. virtual bool intersects(const DrawPoint& point) const; // Get the bounding box for the object. virtual void getBounds(DrawRectangle& rect) const; protected: DrawRectangle rect; // Find the bounding box of a drawing primitive. Returns // true if successful, else returns false. virtual bool findMinMax(DrawPrimitive* prim, int& minx, int& miny, int& maxx, int& maxy) const; }; #endif