script_enemy_main
{
	#include_function ".\Bullet_function.txt"
	#include_function ".\Enemy function.txt"

	@Initialize{
	SetCommonData("E37_X",GetX);
	SetCommonData("E37_Y",GetY);
	SetX(GetCenterX);
	SetY(0);
	SetLife(1);
	SetScore(40000);
	SetDamageRate(0,0);
	LoadGraphic(imgyoukou);
	LoadGraphic(imgzako);
	SetTexture(imgyoukou);
	SetGraphicRect(384,256,512,384);
	Shot(GetArgument);
	Move();
	}

	@MainLoop{
	ChackBonus;
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{

	}

	task Shot(level){
	task RandomShot(level){
	loop(80){yield;}
	loop(300){
	CreateShot01(GetX,GetY,2,rand(0,360),WHITE04,15);
	yield;
	if(level >= 2){CreateShot01(GetX,GetY,2,rand(0,360),WHITE05,15);}
	yield;
	if(level >= 1){CreateShot01(GetX,GetY,2,rand(0,360),WHITE05,15);}
	yield;
	if(level >= 3){CreateShot01(GetX,GetY,2,rand(0,360),WHITE05,15);}
	yield;
	}
	}

	task OutPlayerShot(level){
	let width = [40,30,30,25];
	let wait = [60,50,40,30];
	let a = 0;
	let b = 0;
	SetShotDirectionType(ABSOLUTE);

	loop(80){yield;}

	loop(1200 / wait[level]){
	let angle = 90 + (width[level] / 2) + a;
	let count = 0;

	loop(360 - width[level]){
	CreateShot01(GetX,GetY,1.5,angle,BLUE21,15);
	angle++;
	}

	if(b == 1){a = 20;}
	if(b == 2){a = 0;}
	if(b == 3){a = -20;}
	if(b == 4){a = 0; b = 0;}
	b++;
	if(level >= 2){a += rand(-10,10);}

	loop(wait[level]){yield;}
	}

	}


	RandomShot(level);
	OutPlayerShot(level);
	}


	task Move(){
	yield;
	SetMovePosition02(GetCommonData("E37_X"),GetCommonData("E37_Y"),80);
	loop(1340){yield;}

	loop(10){
	loop(120 + scorebonus * 3){
	let angle = rand(0,360);
	let radius = rand(64,192);
	let x = GetX + cos(angle) * radius;
	let y = GetY + sin(angle) * radius;
	CreateItem(ITEM_SCORE,x,y);}

	yield;}

	FullItemSet(GetX,GetY);

	SetMovePosition02(GetCommonData("E37_X"),0,80);
	loop(80){yield;}
	VanishEnemy;
	}

}