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

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(40);
	SetScore(120);
	SetDamageRate(100,33);
	LoadGraphic(imgzako);
	SetTexture(imgzako);
	SetGraphicRect(192,64,224,96);
	Shot(GetArgument);
	Move();
	}

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

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	SetShotDirectionType(ABSOLUTE);
	if(BeVanished() == false){
	loop(1 + scorebonus){
	let x = GetX + rand(-8,8);
	let y = GetY + rand(-8,8);
	CreateItem(ITEM_SCORE,x,y);
	}
	}
	}

	task Shot(level){

	function StopToShot(x,y,speed,angle,bullet,delay){
	CreateShotA(0,x,y,delay);
	SetShotDataA(0,0,0,angle,0,0,0,bullet);
	SetShotDataA(0,30,speed,angle,0,0,0,bullet);
	FireShot(0);
	}

	loop(50){yield;}
	if(level >= 2){
	let bullet	= [RED04,BLUE04];
	let a = rand_int(0,1);
	loop(level){let speed = 0.95 + level * 0.35;
	StopToShot(GetX+rand(-32,32),GetY+rand(-32,32),speed,rand(0,360),bullet[a],0);
	loop(30 - level * 5){yield;}
	a++;
	if(a > 1){a -= 2;}
	}
	}
	}

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

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

	SetMovePosition02(GetX,GetCenterY-70,150);
	loop(150){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;
	}

}