#TouhouDanmakufu[Stage]
#Title[MedicineStage[Normal]]
#Text[Battle aganist Medicine !!]

Difficulty : Normal
Version : 1.0]
#BackGround[Default]
#PlayLevel[Normal]
#Player[FREE]
#ScriptVersion[2]


script_stage_main
{
	let CSD = GetCurrentScriptDirectory;
	let bg1 = GetCurrentScriptDirectory~"img\bg\stage01.png";
	let bg2 = GetCurrentScriptDirectory~"img\bg\stage02.png";
	let bg3 = GetCurrentScriptDirectory~"img\bg\stage03.png";
	let slide = 0;
	let alpha2 = 0;
	let alpha = 255;
	let color = 162;
	let color2 =  63;
	let a = 0;
	LoadGraphic(bg1);
	LoadGraphic(bg2);
	LoadGraphic(bg3);


//---------------------------------------------------------------
// 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
	{

	PlayMusic(CSD~"music\Medicine.mp3");
	Wait(120);

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


	ClearStage; 
	yield;
	}


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

@Initialize
{
	StageTask();
}


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


@MainLoop
{
	yield;
}

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

@DrawLoop
	{
	}

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

	@BackGround
	{
		if(GetCommonDataDefault("back",0)==1){
		if(alpha>=2.5){alpha-= 2.5;}
		if(color>=3){color -= 2.5;}
		if(color2>=1){color2 -= 2;}
		}
		if(GetCommonDataDefault("back",0)==0){
		if(alpha<255){alpha+= 2.5;}
		if(color<162){color += 2.5;}
		if(color2<63){color2 += 2;}
		}

		SetViewTo(0,0,0);
		SetViewFrom(-240,90,45);
		SetTexture(bg1);
		SetGraphicRect(0,0,512,512+slide/2);
		SetGraphicScale(1,1);
		SetRenderState(ALPHA);
		SetAlpha(alpha);
		DrawGraphic3D(0,0,0);
		

		SetTexture(bg3);
		SetColor(color+color2*sin(slide/3%180), 0, color+color2*sin(slide/3%180));
		SetGraphicRect(0,0,512,512+slide/4.5);
		SetGraphicScale(1,1);
		SetRenderState(ADD);
		SetAlpha(alpha);
		DrawGraphic3D(0,0,0);
		 slide += 1;
	}

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

@Finalize
	{
	}


}
