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

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(20);
	SetScore(50);
	SetDamageRate(100,33);
	LoadGraphic(imgzako);
	SetTexture(imgzako);
	SetGraphicRect(160,64,192,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){
	loop{let speed = 2;
	CreateShot01(GetX,GetY,speed,0,ORANGE05,0);
	CreateShot01(GetX,GetY,speed,180,ORANGE05,0);
	if(level >= 1){
	CreateShot01(GetX,GetY,speed,90,ORANGE05,0);
	CreateShot01(GetX,GetY,speed,270,ORANGE05,0);
	}
	if(level >= 3){
	CreateShot01(GetX,GetY,speed,45,ORANGE05,0);
	CreateShot01(GetX,GetY,speed,135,ORANGE05,0);
	CreateShot01(GetX,GetY,speed,225,ORANGE05,0);
	CreateShot01(GetX,GetY,speed,315,ORANGE05,0);
	}
	loop(20 - level * 4){yield;}
	}
	}

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

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

	if(GetX <= GetCenterX){SetMovePosition02(GetGapX(GetX,700,45),GetGapY(GetX,700,45),150);}
	else if(GetX >= GetCenterX){SetMovePosition02(GetGapX(GetX,700,135),GetGapY(GetX,700,135),150);}
	loop(151){yield;}
	VanishEnemy;
	}

}