//CParticle.cpp

#include <winsock2.h>
#include <iostream.h> // include important C/C++ stuff
#include <conio.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h> 
#include <math.h>
#include <io.h>
#include <fcntl.h>
#include <fstream>
#include <cstdlib>



#include "stringc.h"

#include "Assert.h"

#include "CTextReader.h"
#include "CImage.h"





#include "CParticle.h"


void CParticle::Init(int _x, int _y, int _xv, int _yv, int _LifeSpan, CImage * _Img)
{
	x = _x;
	y = _y;

	xv = _xv;
	yv = _yv;

	LifeSpan = _LifeSpan;
	Img = _Img;

	xa = 0;
	ya = 0;
	za = 0;

	isDead=false;
}


void CParticle::Update()
{
	x += xv;
	y += yv;
	

	xv += xa;
	yv += ya;
	

	LifeSpan--;

	//mod.setColorMod(0xFFD5E800);


	if(LifeSpan > 20)
	{
		//mod.setColorMod(0xFFBA1301);

	}
	else if(LifeSpan > 10)
	{
	//	mod.setColorMod(0xFFDF3F00);
	}
	
	else if(LifeSpan < 10)
	{
		if(Img)
		{
		//	mod.setTransparency(LifeSpan * 10);
			
			//Img->setScale(LifeSpan/10,LifeSpan/10);

			//x +=Img->getWidth()*((LifeSpan)/10);
			//y +=Img->getHeight()*((LifeSpan)/10);

		}
	}
	

	if(LifeSpan==0)
	{
		isDead=true;		
		//Img->setTransparency(100);
	}

}