#include "cCollRect.h"

cCollRect::cCollRect()
{
	SetLeft(0);
	SetTop(0);
	SetRight(0);
	SetBottom(0);
	SetPosition(0,0);
}
cCollRect::cCollRect(double xx, double yy, double l, double t, double r, double b)
{
	SetLeft(l);
	SetTop(t);
	SetRight(r);
	SetBottom(b);
	SetPosition(xx,yy);
}
void cCollRect::SetLeft(double l)
{
	left = l;
}
void cCollRect::SetTop(double t)
{
	top = t;
}
void cCollRect::SetRight(double r)
{
	right = r;
}
void cCollRect::SetBottom(double b)
{
	bottom = b;
}
void cCollRect::SetX(double xx)
{
	x = xx;
}
void cCollRect::SetY(double yy)
{
	y = yy;
}
void cCollRect::SetPosition(double xx, double yy)
{
	SetX(xx);
	SetY(yy);
}

double cCollRect::GetX()
{
	return x;
}
double cCollRect::GetY()
{
	return y;
}
double cCollRect::GetLeft()
{
	return left;
}
double cCollRect::GetTop()
{
	return top;
}
double cCollRect::GetRight()
{
	return right;
}
double cCollRect::GetBottom()
{
	return bottom;
}
bool cCollRect::CollidesWidth(cCollRect *other)
{
	/*
	if left smaller other right
		if right larger other left
			if top smaller than other bottom
				if bottom larger than other top
					hoorah?
	*/
	if (x+GetLeft() < other->GetX()+other->GetRight())
		if (x+GetRight() >= other->GetX()+other->GetLeft())
			if (y+GetTop() < other->GetY()+other->GetBottom())
				if (y+GetBottom() >= other->GetY()+other->GetTop())
					return true;
	return false;
}