#e
#Title[gRCh}`]
#Text[̃XsOtĂK݂Ȃ̂]
#PlayLevel[Normal]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	#include_function ".\lib\Common.dnh"
	#include_function ".\lib\lib_anime_Mokou.dnh"
	
	let name = "gRCh}`\eXg";
	let bossImg = CSD ~ "img\dot_mokou.png";
	let back = CSD ~ "img\back2.png";
	
	let xIni = cx;
	let yIni = GetClipMinY + 64;
	let wIni = 120;
	
	@Initialize {
		SetLife(2500);
		SetDamageRate(30, 30);
		SetScore(2500000);
		SetTimer(60);
		
		LoadUserShotData(CSD ~ "img\shot_All.dnh");
		LoadGraphic(bossImg);
		LoadGraphic(back);
		
		CutIn(YOUMU, name, "", 0, 0, 0, 0);
		
		InitializeAction;
		rand_initialize(1);
		
		TMain;
	}

	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 64);
		yield;
	}

	@DrawLoop {
		DrawBoss(bossImg);
	}

	@Finalize {
		DeleteGraphic(bossImg);
	}

	@BackGround {
		SetGraphicRect(0, 0, 384, 448);
		SetTexture(back);
		DrawGraphic(cx, cy);
	}
	
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
	
	task TMain {
		getReady(wIni);
		yield;
		
		shot(cx, cy, 96, 2/7, 2, -90, 1.5, BLUE + RICE);
		
	}
	
	task shot(_x,			// ~̒ŜW
			 _y, 			// ~̒ŜW
			 _r1, 			// ~̔a
			 _r2, 			// ~̔a1ƂƂ̓~̔a
			 _spin,			// ]@vZ@Ȃ̂ŁAbIɎ蓮œ͂ _r2̈n/mȂn̒lɓƂ悳
			 _baseAngle, 	// ǂ̊px`n߂邩
			 _omega, 		// px
			 _type			// ẽfUC
			 ) {
		let cx1 = _x;
		let cy1 = _y;
		let r1 = _r1;
		let r2 = _r1 * _r2;
		let angle2 = _baseAngle;
		let angle3 = _baseAngle;
		
		let omega = _omega * _spin;		// pẍ̂܂܎gƉ̂x̂ŁAKɕ␳
		
		let cx2;
		let cy2;
		
		let x;
		let y;
		
		let id = 0;
		let w = 400;
		
		loop {
			cx2 = cx1 + cos(angle2) * (r1 - r2);
			cy2 = cy1 + sin(angle2) * (r1 - r2);
			
			x = cx2 + cos(angle3) * r2 * 0.8;
			y = cy2 + sin(angle3) * r2 * 0.8;
			
			CreateShotA(id, x, y, 5);
			SetShotDataA(id, 0, 0, angle3 + 92, 0, 0, 0, _type);
			SetShotDataA(id, w - id, 0.5, NULL, 0, 0.0001, 1, _type);
			FireShot(id);
			
			angle2 += omega;
			angle3 -= omega * (1/_r2 - 1);
			id++;
			yield;
			
			if(angle2 > (360 * _spin) + _baseAngle || angle2 < -(360 * _spin) + _baseAngle) {	// (spin)疳[v痣E
				break;
			}
		}
	}
}