#東方弾幕風
#Title[月土符「レッドエクリプス」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let doll=0;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(600);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(180);
		LoadGraphic(imgExRumia);
		LoadGraphic(GetCurrentScriptDirectory~".\img\ma.png");
		SetTexture(imgExRumia);	
		shottask;
		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 a=0;
		wait(120);
		loop(8)
		{
			CreateEnemyFromScript("family",GetX,GetY,1.5,GetAngleToPlayer,a);	
			a+=45;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy family
{
	let angle=0;
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(1);
		SetDamageRate(0,0);
		SetInvincibility(60);
		SetTexture(GetCurrentScriptDirectory~".\img\ma.png");
		shottask;
		movetask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		SetGraphicAngle(0,0,angle);
		SetGraphicRect(0,0,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
		angle++;
	}
	task shottask
	{
		let s=0;
		let angle=atan2(GetEnemyY-GetY,GetEnemyX-GetX);
		wait(2);
		loop
		{
			angle=atan2(GetEnemyY-GetY,GetEnemyX-GetX);
			CreateShot02(GetX,GetY,0,angle,0.1,2,9,0);
			angle-=90;
			CreateShot02(GetX,GetY,0,angle,0.1,2,12,0);
			angle-=90;
			CreateShot02(GetX,GetY,0,angle,0.1,2,11,0);
			angle-=90;
			CreateShot02(GetX,GetY,0,angle,0.1,2,14,0);
			angle-=90;
			wait(9);
		}
	}
	task movetask
	{
		let r=0;
		let angle=GetArgument;
		let angle2=0;
		loop
		{
			SetX(GetEnemyX+r*cos(angle));
			SetY(GetEnemyY+r*sin(angle));
			angle+=3*sin(angle2);
			angle2++;
			if(r<120)
			{
				r++;
			}
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}