return false;//if none were found then return false.
}
-bool CollisionRectangle::collision(const Collision *c, const Point2D cPos, const Point2D pos){
+bool CollisionRectangle::collision(const Collision *c, const Point2D cPos, const Point2D pos) const {
if(dynamic_cast<const CollisionRectangle*>(c)){
//const CollisionRectangle* rec = dynamic_cast<const CollisionRectangle*>(c);
}
- else if(const CollisionCircle* col = dynamic_cast<const CollisionCircle*>(c)){
- ///col->collision(this, cPos, pos);/// \todo this flips a shit!!!!!!
+ else if(dynamic_cast<const CollisionCircle*>(c)){
+ c->collision(this, cPos, pos);/// \todo this flips a shit!!!!!!
}
return false;
}
-bool CollisionCircle::collision(const Collision *c, const Point2D cPos, const Point2D pos){
- if (dynamic_cast<const CollisionRectangle*>(c)) {
+
+bool CollisionCircle::collision(const Collision *c, const Point2D cPos, const Point2D pos) const {
+ if (const CollisionRectangle* r = dynamic_cast<const CollisionRectangle*>(c)) {
+ collision(r, cPos, pos);///call the circle rect fn
}
else if(const CollisionCircle* col = dynamic_cast<const CollisionCircle*>(c)){
if(((col->mPos + cPos) - (mPos + pos)).length() <= (col->radius + radius))
return false;
}
-bool CollisionCircle::collision(const CollisionRectangle* c, const Point2D cPos, const Point2D pos){
-
+bool CollisionCircle::collision(const CollisionRectangle* c, const Point2D cPos, const Point2D pos) const {
+ return false;
}
\ No newline at end of file
\param pos the current sprite's position.
\return Returns true if any of the object's collision datas are colliding .
*/
- virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos) = 0;
+ virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos) const = 0;
/// \todo See this http://www.metanetsoftware.com/technique/tutorialA.html
virtual void draw(const Point2D& pos) = 0;/**< Draws the collision data to the screen */
protected:
double width;/**< Rectangle's width */
double height;/**< Rectangle's height */
/**
- Check collision with objects
+ Check collision with objects implements rectangle on rectangle
\param c a single collision data for an object
\param cPos the position of the sprite we want to check collision with.
\param pos the current sprite's position.
\return Returns true if any of the object's collision datas are colliding .
*/
- virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos);
+ virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos) const;
virtual void draw(const Point2D& pos);/**< Draws the collision data to the screen */
};
CollisionCircle();
CollisionCircle(Point2D pt, double r) : radius(r){ mPos = pt; }
double radius; /**< The raidus of the circle */
- /**
- Check collision with objects
+ /**
+ This does collision between Rectangles and Circles
\param c a single collision data for an object
\param cPos the position of the sprite we want to check collision with.
\param pos the current sprite's position.
\return Returns true if any of the object's collision datas are colliding .
*/
- virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos);
- /**
- This does collision between Rectangles and Circles
+ bool collision(const CollisionRectangle* c, const Point2D cPos, const Point2D pos) const;
+ /**
+ Check collision with objects implements circle on circle
\param c a single collision data for an object
\param cPos the position of the sprite we want to check collision with.
\param pos the current sprite's position.
\return Returns true if any of the object's collision datas are colliding .
*/
- bool collision(const CollisionRectangle* c, const Point2D cPos, const Point2D pos);
+ virtual bool collision(const Collision *c, const Point2D cPos, const Point2D pos) const;
+
virtual void draw(const Point2D& pos);/**< Draws the collision data to the screen */
};
#endif