
#include "CGameObject.h"
#include "CGraphicSystem.h"


bool CGameObject::isInside(CGameObject* obj)
{
	
	RECT tmp;
	IntersectRect(&tmp, &obj->getBoundingBox(), &m_boundingBox);	

	return !(IsRectEmpty(&tmp));	
}


void CGameObject::Collision(CGameObject* obj)
{

}

void CGameObject::drawBoundingBox()
{
	g_GraphicSystem.DrawRect(m_boundingBox);

}

void CGameObject::Draw()
{

}

void CGameObject::Update()
{

}

void CGameObject::Shutdown()
{

}

/*
	SetX and SetY need to account for the bounding box as well. Not the most optimized code but it works.
 */

void CGameObject::setX(int x)
{
	int dx = m_boundingBox.left - m_Position.x;
	
	m_Position.x = x;
	OffsetRect(&m_boundingBox, -m_boundingBox.left,0);
	OffsetRect(&m_boundingBox, x + dx, 0);
	
}

void CGameObject::setY(int y)
{
	int dy = m_boundingBox.top - m_Position.y;
	
	m_Position.y = y;
	OffsetRect(&m_boundingBox, 0, -m_boundingBox.top);
	OffsetRect(&m_boundingBox, 0, y + dy);
	
}

