2015-05-06 07:05:06 +00:00
|
|
|
#ifndef CRECTANGLE_HPP
|
|
|
|
#define CRECTANGLE_HPP
|
|
|
|
#include "CVector2f.hpp"
|
|
|
|
|
2015-10-08 00:21:38 +00:00
|
|
|
namespace Zeus
|
|
|
|
{
|
2015-05-06 07:05:06 +00:00
|
|
|
class CRectangle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CRectangle() {}
|
|
|
|
|
|
|
|
inline 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline 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-10-08 00:21:38 +00:00
|
|
|
}
|
2015-05-06 07:05:06 +00:00
|
|
|
|
|
|
|
#endif // CRECTANGLE_HPP
|