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

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(400);
	SetScore(10);
	SetDamageRate(100,100);
	LoadGraphic(imgzako);
	SetTexture(imgzako);
	SetGraphicRect(256,0,320,64);
	Shot(GetArgument);
	Move();
	}

	@MainLoop{
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,24);
	ChackBonus;
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	if(BeVanished() == true){
	MasicPointAddNormal(5);
	MagicPowerAdd(true);
	loop(50 + scorebonus){
	let x = GetX + rand(-32,32);
	let y = GetY + rand(-32,32);
	CreateItem(ITEM_SCORE,x,y);
	}
	DeleteEnemyShotToItem(ALL);
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}

	function GetGapX(xA,gapLength,gapAngle){
	return xA + gapLength * cos( gapAngle );
	}

	function GetGapY(yA,gapLength,gapAngle){
	return yA + gapLength * sin( gapAngle );
	}

	let mx = GetClipMinX;
	let Mx = GetClipMaxX;
	let my = GetClipMinY;
	let My = GetClipMaxY;
	let angleA = 0;
	let angleB = 0;
	let wait = [18,15,13,10,7];

	loop{
	DonutShot01(GetX,GetY,16,20 + level * 10,level * 0.34 + 1,angleA,GREEN04,20);
	DonutShot01(GetX,GetY,16,20 + level * 10,level * 0.34 + 1,angleA+180,GREEN04,20);
	DonutShot01(GetX,GetY,16,20 + level * 10,level * 0.34 + 1,angleB,GREEN04,20);
	DonutShot01(GetX,GetY,16,20 + level * 10,level * 0.34 + 1,angleB+180,GREEN04,20);
	if(level >= 1){
	DonutShot01(GetX,GetY,32,10 + level * 10,level * 0.34 + 1,angleA+90,GREEN04,20);
	DonutShot01(GetX,GetY,32,10 + level * 10,level * 0.34 + 1,angleB+90,GREEN04,20);
	DonutShot01(GetX,GetY,32,10 + level * 10,level * 0.34 + 1,angleA+270,GREEN04,20);
	DonutShot01(GetX,GetY,32,10 + level * 10,level * 0.34 + 1,angleB+270,GREEN04,20);
	}
	if(level >= 2){
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleA+45,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleB+45,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleA+135,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleB+135,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleA+225,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleB+225,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleA+315,GREEN04,20);
	DonutShot01(GetX,GetY,64,level * 5,level * 0.34 + 1,angleB+315,GREEN04,20);
	}
	Wait(wait[level]);
	angleA += 23;
	angleB -= 23;
	}
	}

	task Move(){
	SetMovePosition02(GetX,GetCenterY-120,40);
	loop(640){yield;}
	VanishEnemy;
	}

}