2018-10-06 20:39:40 -07:00
|
|
|
#pragma once
|
2018-12-07 17:16:50 -08:00
|
|
|
|
2016-03-04 15:03:26 -08:00
|
|
|
#include "zeus/CVector2f.hpp"
|
2015-05-06 00:05:06 -07:00
|
|
|
|
2018-12-07 17:16:50 -08:00
|
|
|
namespace zeus {
|
|
|
|
class CRectangle {
|
2015-05-06 00:05:06 -07:00
|
|
|
public:
|
2018-12-07 17:16:50 -08:00
|
|
|
CRectangle() {}
|
|
|
|
|
|
|
|
CRectangle(float x, float y, float w, float h) : position(x, y), size(w, h) {}
|
|
|
|
|
|
|
|
bool contains(const CVector2f& point) const {
|
|
|
|
if (point.x() < position.x() || point.x() > position.x() + size.x())
|
|
|
|
return false;
|
|
|
|
if (point.y() < position.y() || point.y() > position.y() + size.y())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool intersects(const CRectangle& rect) const {
|
|
|
|
return !(position.x() > rect.position.x() + rect.size.x() || rect.position.x() > position.x() + size.x() ||
|
|
|
|
position.y() > rect.position.y() + rect.size.y() || rect.position.y() > position.y() + size.y());
|
|
|
|
}
|
|
|
|
|
|
|
|
CVector2f position;
|
|
|
|
CVector2f size;
|
2015-05-06 00:05:06 -07:00
|
|
|
};
|
2018-12-07 21:23:50 -08:00
|
|
|
} // namespace zeus
|