#include "StdAfx.h"
#include "BANG.h"


BANG::BANG(void)
{
	Res	=	new	PARTICLE[5];
	Res[0].LoadImageFromFile(L"Texture/Bang/fire_001.png");
	Res[1].LoadImageFromFile(L"Texture/Bang/fire_01.png");
	Res[2].LoadImageFromFile(L"Texture/Bang/fire_002.png");
//	float siz = 0.91f;
//	Res[0].SetSize(siz,siz);
//	Res[0].DestBlend = 2;
	Res[0].SoursBlend = 2;
//	Res[1].DestBlend = 2;
	Res[1].SoursBlend = 2;
	Res[2].DestBlend = 6;
}
void BANG::Draw(void)
{
	for(int i = 0; i<(int)PSystem.size();i++)
	{
		float k = 1.7f;
		PSystem[i].Flip();
	//	PSystem[i].SetARGB(PSystem[i].GetAlpha()/1.1f);
		PSystem[i].SetARGB(abs(255*(CompileNoise(((float)GetTickCount()/30)-PSystem[i].GetPosition().x/10,PSystem[i].GetPosition().y/10))));
	//	PSystem[i].Acseleration.y = k*0.5*((CompileNoise(PSystem[i].GetPosition().x/0.1,PSystem[i].GetPosition().y/0.1)));
	//	PSystem[i].Acseleration.x = k*((CompileNoise(PSystem[i].GetPosition().x/0.1,PSystem[i].GetPosition().y/0.1)));
		PSystem[i].Draw();

		if(PSystem[i].TimeLive < GetTickCount()-200)
			PSystem.erase(PSystem.begin()+i);
	}
}
void	BANG::AddBoom(float x,float y,int Lenght,int Rot)
{
	if(Rot == MRIGHT)
	{	
		for(int i = 0; i<10;i++)
		{
			int r = 2;
			Res[r].Speed.x = ((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.y = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
		for(int i = 0; i<50;i++)
		{
			int r = rand()%2;
			Res[r].Speed.x = ((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.y = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
	}

	else if(Rot == MDOWN)
	{	
		for(int i = 0; i<10;i++)
		{
			int r = 2;
			Res[r].Speed.y = ((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.x = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
		for(int i = 0; i<50;i++)
		{
			int r = rand()%2;
			Res[r].Speed.y = ((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.x = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
	}

	else if(Rot == MUP)
	{	
		for(int i = 0; i<10;i++)
		{
			int r = 2;
			Res[r].Speed.y = -((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.x = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
		for(int i = 0; i<50;i++)
		{
			int r = rand()%2;
			Res[r].Speed.y = -((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.x = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
	}

	else if(Rot == MLEFT)
	{	
		for(int i = 0; i<10;i++)
		{
			int r = 2;
			Res[r].Speed.x = -((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.y = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
		for(int i = 0; i<50;i++)
		{
			int r = rand()%2;
			Res[r].Speed.x = -((float)(rand()%5000*Lenght)/1000);
			Res[r].Speed.y = 0;
			Res[r].SetPosition(x,y);
			//Res[0].SetPosition(x,y+i*10);
			Res[r].TimeLive = GetTickCount();

			PSystem.push_back(Res[r]);
		}
	}

}
BANG::~BANG(void)
{
}
