import com.terry.engine.*;

//Obj state control: editable functions from obj.

public static function initparticle(t:int):void {
	if (particles[t].type == "pixel") {
		particles[t].life = 45;
	}else if (particles[t].type == "rpgtext") {
		particles[t].colour = particles[t].ax;
		particles[t].ax = 0;
		particles[t].life = 10;
	}
}

public static function updateparticle(i:int):void {
	if (particles[i].type == "rpgtext") {
		if (particles[i].state == 0) {
			particles[i].xp += (Math.random() * 11) - 5;
			particles[i].state=1;
		}else if (particles[i].state == 1) {
			particles[i].yp-=3;
			particles[i].life--;
			if (particles[i].life <= 5) { 
				particles[i].state = 2; 
				particles[i].statedelay = 2; 
			}
		}else if (particles[i].state == 2) {
			particles[i].yp += 3;
			particles[i].life--;
			if (particles[i].life <= 0) particles[i].state = 3;
		}else if (particles[i].state == 3) {
			particles[i].state = 4; particles[i].statedelay = 20;
		}else if (particles[i].state == 4) {
			particles[i].active = false;
		}
	}else {
		particles[i].vx = particles[i].vx + particles[i].ax;
		particles[i].vy = particles[i].vy + particles[i].ay;
		
		particles[i].xp = particles[i].xp + particles[i].vx;
		particles[i].yp = particles[i].yp + particles[i].vy;
		
		particles[i].life--;
		if (particles[i].life <= 0) particles[i].active = false;
	}
}
