【发布时间】:2012-12-17 17:47:33
【问题描述】:
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;
}
【问题讨论】:
-
+ve 起来了吗?如果是这样,它看起来没问题。
标签: c++ algorithm collision-detection