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

	@Initialize{
	SetX(GetX);
	SetY(GetY);
	SetLife(350);
	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);
	loop(50 + scorebonus){
	let x = GetX + rand(-32,32);
	let y = GetY + rand(-32,32);
	CreateItem(ITEM_SCORE,x,y);
	}
	}
	}

	task Shot(level){

	function DelayShot(x,y,speed,angle,Angle,bullet,delay){

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

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

	let x1 = GetClipMinX;
	let x2 = GetClipMaxX;
	let y1 = GetClipMinY;
	let y2 = GetClipMaxY;
	let x3 = x;
	let y3 = y;

	let angleA = Angle;
	while(x3 >= x1&&x3 <= x2&&y3 >= y1&&y3 <= y2){
	CreateShot01(x3,y3,speed,angleA,bullet,delay);
	angleA += 16.7;
	x3 += GetGapX(x4,8,angle);
	y3 += GetGapY(y4,8,angle);
	}
	}

	DelayShot(GetX,GetY,2,45,90,GREEN04,150);
	DelayShot(GetX,GetY,2,135,90,RED04,150);
	DelayShot(GetX,GetY,2,225,90,AQUA04,150);
	DelayShot(GetX,GetY,2,315,90,YELLOW04,150);
	if(level >= 1){
	DelayShot(GetX,GetY,2,90,90,PURPLE04,150);
	DelayShot(GetX,GetY,2,270,90,WHITE04,150);
	DelayShot(GetX,GetY,2,45,0,GREEN04,150);
	DelayShot(GetX,GetY,2,135,0,RED04,150);
	DelayShot(GetX,GetY,2,225,0,AQUA04,150);
	DelayShot(GetX,GetY,2,315,0,YELLOW04,150);
	}
	if(level >= 2){
	DelayShot(GetX,GetY,2,0,90,BLUE04,150);
	DelayShot(GetX,GetY,2,180,90,ORANGE04,150);
	}
	if(level >= 3){
	DelayShot(GetX,GetY,2,0,0,BLUE04,150);
	DelayShot(GetX,GetY,2,90,0,PURPLE04,150);
	DelayShot(GetX,GetY,2,180,0,ORANGE04,150);
	DelayShot(GetX,GetY,2,270,0,WHITE04,150);
	}
	loop(300){yield;}

	DelayShot(GetX,GetY,2,45,270,GREEN04,150);
	DelayShot(GetX,GetY,2,135,270,RED04,150);
	DelayShot(GetX,GetY,2,225,270,AQUA04,150);
	DelayShot(GetX,GetY,2,315,270,YELLOW04,150);
	if(level >= 1){
	DelayShot(GetX,GetY,2,90,270,PURPLE04,150);
	DelayShot(GetX,GetY,2,270,270,WHITE04,150);
	DelayShot(GetX,GetY,2,45,180,GREEN04,150);
	DelayShot(GetX,GetY,2,135,180,RED04,150);
	DelayShot(GetX,GetY,2,225,180,AQUA04,150);
	DelayShot(GetX,GetY,2,315,180,YELLOW04,150);
	}
	if(level >= 2){
	DelayShot(GetX,GetY,2,0,270,BLUE04,150);
	DelayShot(GetX,GetY,2,180,270,ORANGE04,150);
	}
	if(level >= 3){
	DelayShot(GetX,GetY,2,0,180,BLUE04,150);
	DelayShot(GetX,GetY,2,90,180,PURPLE04,150);
	DelayShot(GetX,GetY,2,180,180,ORANGE04,150);
	DelayShot(GetX,GetY,2,270,180,WHITE04,150);
	}
	}

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

}