#TouhouDanmakufu[Stage]
#Title[Keine Lunatic]
#Text[]
#Player[FREE]
#ScriptVersion[2]

script_stage_main
{
   let bgm=GetCurrentScriptDirectory~"keinebgm.mp3";
   let bg_distance = 0;
   let bg_distanceb = 0;
   let bg_distancec = 0;
   let bg_img = GetCurrentScriptDirectory~"img\stbga.png";
   let bg_imgb = GetCurrentScriptDirectory~"img\stbgb.png";

task stage
{
	loop(100){yield;}
	PlayMusic(bgm);
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Keine_l.txt", GetCenterX, GetClipMinY, 0, 0, 0);
	while(GetEnemyNum!=0){yield;}
	loop(60){yield;}
	Clear;
}
   @Initialize
   {
	LoadGraphic(bg_img);
	LoadGraphic(bg_imgb);
	stage;
   }

   @MainLoop
   {
	yield;
   }

   @DrawLoop
   {
   }

   @BackGround
   {
	bg_distance++;
	if(bg_distance>256)
	{
	bg_distance-=256;
	}
	bg_distanceb+=1.25;
	if(bg_distanceb>256)
	{
	bg_distanceb-=256;
	}
	bg_distancec+=0.5;
	if(bg_distancec>256)
	{
	bg_distancec-=256;
	}
	WriteZBuffer(true);
	UseZBuffer(true);

	SetTexture(bg_imgb);
	SetGraphicRect(0, 0, 256, 256);
	SetGraphicScale(1, 1);
	SetGraphicAngle(0, 0, 0);
	SetRenderState(ALPHA);
	ascent(i in -2..3)
	{
	ascent(j in -4..5)
	{
	DrawGraphic(i*256+bg_distance, j*256+bg_distance);
	}
	}
	
	SetTexture(bg_img);
	SetGraphicRect(-512, -512, 512, 512);
	SetGraphicScale(1, 1);
	SetGraphicAngle(0, 0, 0);
	SetRenderState(ALPHA);
	DrawGraphic(GetCenterX, GetCenterY+bg_distanceb);
	DrawGraphic(GetCenterX, GetCenterY-bg_distancec);
   }

   @Finalize
   {
   }
}
