task SakuraCharge(color)
{
	ascent(i in 0..10)
	{
		let randdegree = rand(0,60);
		ascent(j in 0..6)
		{
			Sakura(90+i*3,j*60+randdegree,color);
		}
		if(i==5){CircleCharge(color);}
		wait(3);
	}
}

task SakuraCharge2(color)
{
	ascent(i in 0..30)
	{
		let randdegree = rand(0,60);
		ascent(j in 0..6)
		{
			Sakura(90+i*3,j*60+randdegree,color);
		}
		if(i==25){CircleCharge(color);}
		wait(3);
	}
}

task CircleCharge(color)
{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let img = GetCurrentScriptDirectory~"image/burst.png";
	let size = 3;
	let acc = 0;
	let co = GetColor(color);
	ObjPrim_SetTexture(obj, img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_RGB);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ManageSize;
	ManageColor;
	task ManageSize
	{
		while(size>0 && !Obj_IsDeleted(objEnemy))
		{
			ObjRender_SetPosition(obj,GetEnemyX,GetEnemyY,0);
			ObjRender_SetScaleXYZ(obj,size,size,0);
			size -= acc;
			acc += 0.0035;
			yield;
		}
		Obj_Delete(obj);
	}
	task ManageColor
	{
		ascent(i in 0..30)
		{
			ObjRender_SetColor(obj,i*co[0]/45,i*co[1]/45,i*co[2]/45);
			yield;
		}
		descent(i in 0..30)
		{
			ObjRender_SetColor(obj,i*co[0]/45,i*co[1]/45,i*co[2]/45);
			yield;
		}
	}
}

task Sakura(r,degree,color)
{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let img = GetCurrentScriptDirectory~"image/sakura.png";
	let acc = 0.5;
	let ang = [rand(-30,30),rand(-30,30),rand(0,360)];
	let co = GetColor(color);
	ObjPrim_SetTexture(obj, img);
	ObjSprite2D_SetSourceRect(obj,0,0,64,64);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetColor(obj,co[0]/2,co[1]/2,co[2]/2);
	ObjRender_SetScaleXYZ(obj,0.5,0.5,0);
	while(r>0 && !Obj_IsDeleted(objEnemy))
	{
		ObjRender_SetPosition(obj,GetEnemyX+r*cos(degree),GetEnemyY+r*sin(degree),0);
		ObjRender_SetScaleXYZ(obj,0.6-acc/100,0.6-acc/100,0);
		ObjRender_SetAngleXYZ(obj,ang[0]+acc*10,ang[1]+acc*10,ang[2]);
		r-=acc;
		acc+=0.2;
		yield;
	}
	Obj_Delete(obj);
}

function GetColor(type){
	if(type=="RED"){return [255,32,32];}
	if(type=="ORANGE"){return [255,128,32];}
	if(type=="YELLOW"){return [255,255,32];}
	if(type=="GREEN"){return [32,255,32];}
	if(type=="BLUE"){return [32,32,255];}
	if(type=="PURPLE"){return [255,32,255];}
	if(type=="PINK"){return [255,32,128];}
	if(type=="WHITE"){return [255,255,255];}
	if(type=="AQUA"){return [0,255,255];}
	if(type=="WHITE"){return [255,255,255];}
	}