2012-01-19 03:30:22 -07:00
|
|
|
coord2d(uint16_t _x, uint16_t _y) : x(_x), y(_y) {}
|
|
|
|
|
|
|
|
bool isValid() const { return x != -30000; }
|
|
|
|
void clear() { x = y = -30000; }
|
|
|
|
|
|
|
|
bool operator==(const coord2d &other) const
|
|
|
|
{
|
|
|
|
return (x == other.x) && (y == other.y);
|
|
|
|
}
|
|
|
|
bool operator!=(const coord2d &other) const
|
|
|
|
{
|
|
|
|
return (x != other.x) || (y != other.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(const coord2d &other) const
|
|
|
|
{
|
|
|
|
if (x != other.x) return (x < other.x);
|
|
|
|
return y < other.y;
|
|
|
|
}
|
|
|
|
|
2012-02-02 11:14:49 -07:00
|
|
|
coord2d operator+(const coord2d &other) const
|
|
|
|
{
|
|
|
|
return coord2d(x + other.x, y + other.y);
|
|
|
|
}
|
|
|
|
coord2d operator-(const coord2d &other) const
|
|
|
|
{
|
|
|
|
return coord2d(x - other.x, y - other.y);
|
|
|
|
}
|
|
|
|
|
2012-01-19 03:30:22 -07:00
|
|
|
coord2d operator/(int number) const
|
|
|
|
{
|
2012-04-01 18:44:35 -06:00
|
|
|
return coord2d((x < 0 ? x - number : x)/number, (y < 0 ? y - number : y)/number);
|
2012-01-19 03:30:22 -07:00
|
|
|
}
|
|
|
|
coord2d operator*(int number) const
|
|
|
|
{
|
|
|
|
return coord2d(x*number, y*number);
|
|
|
|
}
|
|
|
|
coord2d operator%(int number) const
|
|
|
|
{
|
2012-04-01 18:44:35 -06:00
|
|
|
return coord2d((x+number)%number, (y+number)%number);
|
2012-01-19 03:30:22 -07:00
|
|
|
}
|
2012-04-10 08:21:19 -06:00
|
|
|
coord2d operator&(int number) const
|
|
|
|
{
|
|
|
|
return coord2d(x&number, y&number);
|
|
|
|
}
|