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

	@Initialize{
	SetX(GetX);
	SetY(GetClipMinY - 16);
	SetLife(10);
	SetScore(30);
	SetDamageRate(100,33);
	LoadGraphic(imgzako);
	SetTexture(imgzako);
	SetGraphicRect(0,192,32,224);
	Shot(GetArgument);
	Move();
	SetInvincibility(50);
	}

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

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	if(BeVanished() == false){
	MasicPointAddNormal(0.5);
	MagicPowerAdd(false);
	loop(4 + scorebonus){
	let x = GetX + rand(-12,12);
	let y = GetY + rand(-12,12);
	CreateItem(ITEM_SCORE,x,y);
	}
	}
	}

	task Shot(level){
	loop{
	loop(40){yield;}
	let angle = GetAngleToPlayer;
	loop(level * 2){
	CreateWayShot01(level + 1,13,GetX,GetY,1.8,angle,YELLOW04,15);
	loop(70){yield;}
	}
	}
	}

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

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

	SetMovePosition02(GetX,GetClipMinY+48,27);
	loop(27){yield;}
	let angle = 0;
	while(angle < 90){
	if(GetX >= GetCenterX){SetMovePosition02(GetGapX(GetX,2,270-angle),GetGapY(GetY,2,270-angle),1);}
	else if(GetX <= GetCenterX){SetMovePosition02(GetGapX(GetX,1,-90+angle),GetGapY(GetY,1,-90+angle),1);}
	yield;
	angle += 2;
	}
	if(GetX <= GetCenterX){SetMovePosition02(GetClipMaxX,GetY,80);}
	else if(GetX >= GetCenterX){SetMovePosition02(GetClipMinX,GetY,80);}
	loop(80){yield;}
	VanishEnemy;
	}

}