script_enemy_main{
	
	let ThisShot = GetCurrentScriptDirectory~"system\supershot.txt";
	let CSD = GetCurrentScriptDirectory;
	let imgFam = CSD ~ "img\circle6_s.png";
	let switch = 1;
	let famangle = GetArgument;
	let spin = 0;
	let count = 0;
	let angle = 0;
@Initialize{
	LoadUserShotData(ThisShot);
	SetLife(40);
	LoadGraphic(imgFam);
	maintask;
}

@MainLoop{
	if ((GetKeyState(VK_SLOWMOVE)==KEY_PUSH) || (GetKeyState(VK_SLOWMOVE)==KEY_HOLD) == false)
	{
	SetCollisionA(GetX, GetY, 24);
	SetCollisionB(GetX, GetY, 16);
	}
	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH){
	PlaySE(CSD~"sound\Hidden.wav");
	}
	else if(GetKeyState(VK_SLOWMOVE)==KEY_PULL){
	PlaySE(CSD~"sound\Sudden.wav");
	}
	if(GetX>GetClipMaxX || GetX<GetClipMinX){VanishEnemy;}
	if(GetY>GetClipMaxY || GetY<GetClipMinY){VanishEnemy;}
yield;
}
	
@DrawLoop{
	SetTexture(imgFam);
	SetRenderState(ALPHA);
	SetGraphicScale(0.8,0.8);
	SetGraphicAngle(0,0,spin);
	SetGraphicRect(64,0,128,64);
	DrawGraphic(GetX,GetY);
	spin -= 2;
}

@Finalize{
	DeleteEnemyShotToItemInCircle(SHOT,GetX,GetY,40);
	ascent(i in 0..3){
	Bullet(GetX,GetY,rand(0.5,1.5),rand_int(0,359),64,0,1);
	Bullet(GetX,GetY,rand(0.5,1.5),rand_int(0,359),65,0,1);
	Bullet(GetX,GetY,rand(0.5,1.5),rand_int(0,359),63,0,1);
	Bullet(GetX,GetY,rand(0.5,1.5),rand_int(0,359),58,0,1);
	}
	//DeleteGraphic(imgFam);

}

task maintask{
	fire;
	yield;
	}

task fire{
	loop{
	if ((GetKeyState(VK_SLOWMOVE)==KEY_PUSH) || (GetKeyState(VK_SLOWMOVE)==KEY_HOLD) == false)
	{
	CreateShotA(0,GetX,GetY,15);
	SetShotDataA(0,0,0,0,0,0,0,201);
	SetShotKillTime(0,0);
	FireShot(0);
	}
	yield;
	wait(2);
	}
	}

task Bullet(x, y, v, dir, graphic, delay,check) 
	{
    	 let obj = Obj_Create(OBJ_SHOT);
    	 Obj_SetPosition   (obj, x, y);
    	 Obj_SetSpeed      (obj, v);
    	 Obj_SetAngle      (obj, dir);
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
	  ObjShot_SetBombResist(obj, true);
		 while(! Obj_BeDeleted(obj)) 
		{
		 yield;
		}
	}

	function wait(w){
		loop(w){yield;}
			}

}
}