#東方弾幕風
#Title[偏西「空を運ぶ風」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let compus=GetCurrentScriptDirectory~"img\背景.png";
	let forest=GetCurrentScriptDirectory~"img\背景2.png";
	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(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		LoadGraphic(compus);
		LoadGraphic(forest);
		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
	{
		SetTexture(imgExRumia);	
		SetGraphicRect(1,1,64,64);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		DrawGraphic(GetX,GetY);
	}
	@BackGround
	{
		SetTexture(compus);	
		SetGraphicRect(1,1,750,720);
		SetAlpha(255);
		SetGraphicScale(0.5,0.5);
		SetGraphicAngle(0,0,count);
		DrawGraphic(cx,cy);
		SetTexture(forest);	
		SetGraphicRect(1,1,450,294);
		SetAlpha(255);
		SetGraphicScale(1.55,1.55);
		SetGraphicAngle(0,0,0);
		DrawGraphic(cx,cy);
		count++;
	}
	task shottask
	{
		let s=0;
		let s2=1;
		let s3=2;
		let s4=3;
		wait(120);
		loop
		{	
			loop(6)
			{
				CreateShotA(s2,GetClipMinX,rand(GetClipMinY,GetClipMinY+180),0);	
				SetShotDataA(s2,0,1,0,0,0,2,48);
				CreateShotA(s3,0,0,0);
				SetShotDataA(s3,0,2,80,0,0,3,78);
				AddShot(rand(0,GetClipMaxX),s2,s3,0);
				FireShot(s2);
				wait(4);
			}	
			CreateShotA(s2,GetClipMinX,rand(GetClipMinY,GetClipMinY+180),0);	
			SetShotDataA(s2,0,1,0,0,0,2,48);
			CreateShotA(s3,0,0,0);
			SetShotDataA(s3,0,1,80,0,0,3,78);
			CreateLaserA(s4,0,0,512,16,155,30);
			SetLaserDataA(s4,0,80,0,0,0,0);
			SetShotKillTime(s4,60);
			AddShot(rand(0,GetClipMaxX),s2,s4,0);
			AddShot(rand(0,GetClipMaxX),s2,s3,0);
			FireShot(s2);
			wait(4);
		}

	}
	task shottask2
	{
		let s=0;
		wait(120);
		loop
		{
			shot(s,GetClipMinX,rand(GetClipMinY,GetClipMaxY));
			wait(4);
		}
	}
	function shot(let shotid,let shotx,let shoty)
	{
		CreateShotA(shotid,shotx,shoty,0);
		SetShotDirectionType(ABSOLUTE);
		SetShotDataA(shotid,0,rand(1.5,2.5),0,0,0,0,112);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}