#include "CBlockObject.h"
#include "CObjectManager.h"
#include "CConsole.h"

//----------------------------------------------------------------//
//	Constructor/Deconstructor
//----------------------------------------------------------------//

CBlockObject::CBlockObject()
{


}

CBlockObject::~CBlockObject()
{



}

void CBlockObject::Init(STRINGC fn, int x, int y)
{

	this->typ=typBlock;		//IMPORTANT!!!

	m_Img = g_GraphicSystem.LoadCImage(fn);
	
	//You MUST set these to zero before setting the bounding box!!!
	m_Position.x=0;	
	m_Position.y=0;
		

	//setup bounding box.
	//For the player we're going to make it the bottom half of the image	
	SetRect(&m_boundingBox,0,0,m_Img->getWidth(),m_Img->getHeight());

	//Ok the bounding box is set. Now whenever we move the player we move the bounding box. And everything takes care of itself.
	//(this is done in the CGameObject's default method of setX and setY)

	setX(x);
	setY(y);

	m_Breakable = false;

	
	
}

//----------------------------------------------------------------//
//	Draw/Update
//----------------------------------------------------------------//

void CBlockObject::Draw()
{
	
	if(m_Img)
	{			
		g_GraphicSystem.DrawCImage(m_Img, m_Position.x, m_Position.y);
	}

//	this->drawBoundingBox();
	

}

void CBlockObject::Update()
{
	



}


void CBlockObject::Collision(CGameObject* obj)
{

	//Block doesn do much. It should blowup if it gets hit with fire. But we dont have 
	//a proper way of removing an object from the game.

	switch(obj->typ)
	{

	case typExplosion:
		
		g_Console.AddMessage("Collision");
		
		if(m_Breakable==true)
		{
			
			g_ObjectManager.RemoveObjectSafe(this->ID);
		}
		
		break;

	default:

		break;

	}

	

}