value>>yOffset;
double radius;
value>>radius;
- mAnim[count].bounds.push_back(CollisionCircle(Point2D(xOffset, yOffset), radius));
+ mAnim[count].bounds.push_back(new CollisionCircle(Point2D(xOffset, yOffset), radius));
}
else if(c == 'r')
{
double width = 0.0 , height = 0.0;
value>>width;
value>>height;
- mAnim[count].bounds.push_back(CollisionRectangle(Point2D(xOffset, yOffset), width, height));
+ mAnim[count].bounds.push_back(new CollisionRectangle(Point2D(xOffset, yOffset), width, height));
}
value>>c;
}
SizeD mScreenSize;///<This is the size of the screen to be drawn to. used to get the sections of the background when moving and for screen-at-a-time scrolling.
SDL_Rect source;///< This is the rectangle that gets taken from the actual background image (h,w) determine the size of the rectangle to sample from the background image. (x,y) determine the position of the rectangle's top left corner on the actual background image.
bool wrapping;
- vector<Collision> collisionData;///<The collision data for this Background \todo implement collisions
+ vector<Collision*> collisionData;///<The collision data for this Background \todo implement collisions
public:
#include "Collision.h"
-bool CollisionRectangle::collision(CollisionRectangle &c){
+bool CollisionRectangle::collision(const Collision *c){
+ if(dynamic_cast<const CollisionRectangle*>(c)){
+ }
+ else if(dynamic_cast<const CollisionCircle*>(c)){
+ }
+
+ return false;
}
-bool CollisionRectangle::collision(CollisionCircle &c){
-}
-bool CollisionCircle::collision(CollisionRectangle &c){
-}
-bool CollisionCircle::collision(CollisionCircle &c){
+bool CollisionCircle::collision(const Collision *c){
+ if (dynamic_cast<const CollisionRectangle*>(c)) {
+ }
+ else if(dynamic_cast<const CollisionCircle*>(c)){
+ }
+
+ return false;
}
public:
Collision():pos(0.0,0.0){}
Point2D pos;/**< The position of the center of the collision data */
- virtual bool collision(CollisionRectangle &c);/**< Check collision with Rectangle */
- virtual bool collision(CollisionCircle &c);/**< Check collision with Circle */
+ virtual bool collision(const Collision *c) = 0; /**< Check collision with objects */
/// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
protected:
string name;///< Name of this behavior \todo make this actually be useful
CollisionRectangle(Point2D pt, double w, double h):width(w),height(h){ pos = pt;}
double width;/**< Rectangle's width */
double height;/**< Rectangle's height */
-
- bool collision(CollisionRectangle &c);/**< Check collision with Rectangle */
- bool collision(CollisionCircle &c);/**< Check collision with Circle */
+ virtual bool collision(const Collision *c);/**< Check collision with objects */
};
/**
{
public:
CollisionCircle();
- CollisionCircle(Point2D pt, double r):radius(r){ pos = pt; }
- double radius;/**< The raidus of the circle */
-
- bool collision(CollisionRectangle &c);/**< Check collision with Rectangle */
- bool collision(CollisionCircle &c);/**< Check collision with Circle */
+ CollisionCircle(Point2D pt, double r) : radius(r){ pos = pt; }
+ double radius; /**< The raidus of the circle */
+ virtual bool collision(const Collision *c);/**< Check collision with objects */
+ bool collision(const CollisionRectangle*);/**< This does collision between Rectangles and Circles */
};
#endif
int height;/**< Base height of the frame's image. */
vector<Point2D> hotSpots;/**< Hot spots that can be used for locating objects on the sprite default is tagged to center of the sprite \todo implement default*/
Point2D animationPeg;/**< The offeset from position to place the image. Defaults to (0,0) \todo implement */
- vector<Collision> bounds;/**< The collision data for this sprite */
+ vector<Collision*> bounds;/**< The collision data for this sprite */
};
#endif
\ No newline at end of file