#include <hge.h>
#include <hgesprite.h>
#include <hgeparticle.h>
#include <math.h>
#include <mmsystem.h>
//#include "Barrier.h" 
#include "Global.h"

TBarrier::TBarrier()
{
	ZeroMemory(Bar, sizeof(Bar));
	texType1 = hge->Texture_Load("Block.bmp");
	sprType1 = new hgeSprite(texType1, 0, 0, 52, 52);
}

TBarrier::Add(float x, float y, int BarType)
{
	int Index = -1;

	for(int i=0; i<100; i++)
	{
		if(Bar[i].type==0)
		{
			Index = i;
			break;
		}

	}

	if(Index != -1)
	{
		Bar[Index].type = BarType;
		Bar[Index].x = x;
		Bar[Index].y = y;

		if(BarType == 1)
		{
			Bar[Index].height = 50;
			Bar[Index].width = 50;
			Bar[Index].DecSpeed = 0;
			Bar[Index].SensitiveX = x+10;			
			Bar[Index].SensitiveY = y+10;			
			Bar[Index].SensitiveHeight = 50-20;	
			Bar[Index].SensitiveWidth = 50-20;	
		}
	}
}


TBarrier::Delete(int Index)
{
	Bar[Index].DecSpeed = 0;
	Bar[Index].height = 0;
	Bar[Index].width = 0;
	Bar[Index].x = 0;
	Bar[Index].y = 0;
	Bar[Index].type = 0;
}

TBarrier::Update(float dt)
{

}

TBarrier::Render(float X, float Y)
{

	for(int i=0; i<100;i++)
	{
		if(Bar[i].type != 0)
		{
			sprType1->Render(Bar[i].x-X, Bar[i].y-Y);
		}
	}
}