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

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(350);
	SetScore(200);
	SetDamageRate(100,33);
	LoadGraphic(imgzako);
	SetTexture(imgzako);
	SetGraphicRect(0,128,32,160);
	Shot(GetArgument);
	Move();
	}

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

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	if(BeVanished() == false){
	MasicPointAddNormal(1.5);
	MagicPowerAdd(true);
	loop(6 + scorebonus){
	let x = GetX + rand(-8,8);
	let y = GetY + rand(-8,8);
	CreateItem(ITEM_SCORE,x,y);
	}
	}
	}

	task Shot(level){

	function GetGapAngle(xA,yA,xB,yB)
	{return atan2( yB - yA, xB - xA );}

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

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

	loop{
	loop(30){yield;}

	let angle = 90;
	let speed = 1.5 + level * 0.75;
	Allshot(speed,90,18 + level * 14,RED32,15);
	loop(18 + level * 14){
	CreateShotA(1,GetX,GetY,15);
	SetShotDataA(1,0,1.5,angle,0,0,0,RED32);
	SetShotDataA(1,20,0,0,0,0,0,RED32);
	SetShotDataA(1,80,speed,GetGapAngle(GetGapX(GetX,30,angle),GetGapY(GetY,30,angle),GetPlayerX,GetPlayerY),0,0,0,RED32);
	FireShot(1);
	angle += 360 / (18 + level * 14);
	}

	loop(100/(level + 1)){yield;}
	}
	}

	task Move(){
	SetMovePosition02(GetX,GetClipMaxY+32,400);
	loop(450){yield;}
	VanishEnemy;
	}

}