class Rectangle{
public:
float x, y, width, height;
// (x,y) is the lower left corner of the rectangle
};
这个算法正确吗?
bool Rectangle::colidesWith(Rectangle other) {
if (x+width < other.x) return false; // "other" is on the far right
if (other.x+other.width < x) return false; //"other" is on the far left
if (y+height < other.y) return false // "other" is up
if (other.y+other.height < y) return false // "other" is down
return true;
}