/* * MovingObjectClass.h * * Virtual MovingObject class definition. * */ #ifndef MOVINGOBJECTCLASS_H #define MOVINGOBJECTCLASS_H #include "PosClasses.h" class MovingObject { protected: intPos old; // Desc: The previous center of the object; // Range: 0 < n < size-of-window; // Usage: Set and updated in moveOnScreen(); // Usage: Used in erase() to erase the old image; // Init: UNDEFINED floatPos center; // Desc: The center of the object, relative to the screen; // Range: 0 < n < 1; // Usage: Multiply by GameData.windowSize for exact pixels; // Init: 0.5, 0.5; floatPos vector; // Desc: The velocity and direction of the object; // Range: 0 < n < .001 Suggested: .0005; // Usage: Added to the center during the update event; // Init: 0, 0; float radius; // Desc: The general radius of the object (litteral radius for Astroids); // Range: ? Suggested: ? // Usage: Used when updating bounds; // Init: 0; Rect bounds; // Desc: The space around the object. Absolute coordinates. // Range: Data.windowSize; // Usage: Updated in draw(); Checked in CollisionDetection(); // Init: UNDEFINED; public: MovingObject(); // Default constructor; Initializes variables; MovingObject(floatPos, floatPos, float); // Construction for initializing center, vector, and radius; virtual ~MovingObject(); // Destructor; void setCenter(floatPos); void setVector(floatPos); void setVector(float, float); void setRadius(float); Rect* Bounds(); // Desc: returns a pointer to the bounds Rect; void moveOnScreen(void*); // Desc: Updates Old and center, calls erase(), calls draw(); // Usage: Must be called for each object every time through the loop; // Params: A pointer to the game data, used for updating the bounds properly. virtual void erase(WindowRef) =0; // Desc: Erases the object based on the Old location; // Usage: Called by MoveOnScreen(), called when an item is destroyed; virtual void draw(WindowRef) =0; // Desc: Draws the object; // Usage: Called by MoveOnScreen(), called upon object creation; // Func: Updates bounds for the new location. virtual void destroy() =0; // Desc: Erases and deallocates the object; // Usage: Called by CollisionDetection; // Public Data Members: MovingObject* next; MovingObject* prev; }; #endif