#東方弾幕風
#Title[紋符「篭目模様の中の鳥」]
#Text[試作]
#ScriptVersion[2]

script_enemy_main
{
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgback=GetCurrentScriptDirectory~"img\RyuukaBack.png";
	let angle=0;
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(500);
		SetDamageRate(10,8);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(150);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		shottask2;
		CutIn(YOUMU,"紋符「篭目模様の中の鳥」",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		SetShotAutoDeleteClip(512,512,512,512);
		let s=0;
		let x=0;
		let y=0;
		let angle=120;
		wait(120);
		loop
		{
			x=GetClipMinX;
			angle=120;
			loop(6)
			{
				CreateShot01(x,GetClipMinY,3,angle,80,0);
				x+=120;
			}
			x=GetClipMinX-120;
			angle=60;
			loop(6)
			{
				CreateShot01(x,GetClipMinY,3,angle,80,0);
				x+=120;
			}
			y=GetClipMinY+30*3^0.5;
			angle=0;
			loop(6)
			{
				CreateShot01(GetClipMinX,y,3,angle,80,0);
				y+=60*3^0.5;
			}
			wait(9);
		}
	}
	task shottask2
	{
		let s=0;
		wait(180);
		loop
		{
			wait(15);
			shot(s,rand(GetClipMinX,GetClipMaxX),GetClipMaxY+32,270);
			shot(s,rand(GetClipMinX,GetClipMaxX),GetClipMinY-32,90);
			shot(s,GetClipMaxX+32,rand(GetClipMinY,GetClipMaxY),180);
			shot(s,GetClipMinX-32,rand(GetClipMinY,GetClipMaxY),0);
		}
	}
	function shot(let shotid,let shotx,let shoty,let angle)
	{
		CreateShotA(shotid,shotx,shoty,0);
		SetShotDirectionType(ABSOLUTE);
		SetShotDataA(shotid,0,2,angle,0,0,0,80);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}