#TouhouDanmakufu[Stage]
#Title[Flan Stage[Lunatic]]
#Text[Battle aganist Flandre Scarlet !!]

Difficulty : Lunatic
Version : 1.1]
#BackGround[Default]
#PlayLevel[Lunatic]
#Player[FREE]
#ScriptVersion[2]


script_stage_main
{
	let CSD = GetCurrentScriptDirectory;
	let StageBG01 = GetCurrentScriptDirectory~"img\bg\stage01.png";
	let StageBG02 = GetCurrentScriptDirectory~"img\bg\stage02.png";
	let bgl1_sc = 0;
	let bgl2_sc = 0;
	let slided = 0;
	let alpha2 = 0;
	let alphac = 0;

	LoadGraphic(StageBG01);
	LoadGraphic(StageBG02);


//---------------------------------------------------------------
// Any Task

//----- Wait for a period
	function Wait(n)
	{
		loop(n) {	yield;	}
	}

//----- Wait until all enemy kill
	function WaitForZeroEnemy()
	{
		while(GetEnemyNum() != 0) {	yield;	}
	}





	task StageTask
	{


	Wait(120);

	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"\FlanL.txt",GetCenterX,GetClipMinY,0,0,0);
	WaitForZeroEnemy;
	Wait(120);


	ClearStage; 
	yield;
	}


//---------------------------------------------------------------

@Initialize
{
	LoadGraphic(StageBG01);
	LoadGraphic(StageBG02);
	StageTask();
}


//---------------------------------------------------------------


@MainLoop
{
	slided+=1.5;
	yield;
}

//---------------------------------------------------------------

@DrawLoop
	{
	}

//---------------------------------------------------------------

	@BackGround
	{
		
		SetTexture(StageBG02);
		SetRenderState(ALPHA);
		SetAlpha(alpha2+80);
		SetGraphicRect(0,0,256,256);
		SetGraphicScale(2,2);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);

		SetTexture(StageBG01);
		SetRenderState(ALPHA);
		SetAlpha(50);
		SetGraphicRect(0,0,256,256+slided);
		SetGraphicScale(2,2);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);

		if(alphac==0){alpha2++;}
		if(alpha2==150){alphac=1;}
		if(alphac==1){alpha2--;}
		if(alpha2==0){alphac=0;}
	}

//---------------------------------------------------------------

@Finalize
	{
	DeleteGraphic(StageBG01);
	DeleteGraphic(StageBG02);
	}


}
