#東方弾幕風
#Title[遠近「ドップラーサイクロン」]
#Text[試作]
#ScriptVersion[2]

script_enemy_main
{
	let cx=GetCenterX();
	let cy=GetCenterY();
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(300);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		movetask;
		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
	{
		let angle=0;
		let color=1;
		let s=0;
		let s2=1;
		wait(120);
		loop
		{
			color=6;
			loop(2)
			{
				loop(180)
				{
					yield;
					SetShotDirectionType(ABSOLUTE);
					CreateShotA(s,GetX,GetY,20);	
					SetShotDataA(s,0,1.5,rand(angle-1,angle+1),0,0,0,color);
					FireShot(s);
					angle+=5
				}
				wait(30);
				color=1;
			}
		}
	}
	task movetask
	{
		wait(120);
		loop
		{
			SetSpeed(1);
			SetAngle(90);
			wait(180);
			SetSpeed(0);
			wait(30);
			SetSpeed(1);
			SetAngle(-90);
			wait(180);
			SetSpeed(0);
			wait(30);
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}