#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//@_FĒe
	let imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_red.png";//摜ݒA
	#include_function".\lib\lib_common.txt"
	#include_function".\lib\lib_anime_Zako.txt"
	@Initialize
	{
		SetLife(100);
                InitializeAction();
                Tmain;
	}
	
	@MainLoop
	{
                if(GetY<cmy-32||GetY>cmY+32||GetX<cmx-32||GetX>cmX+32){VanishEnemy();}
		SetCollisionA(GetX(),GetY(),32);//蔻(e)o^
		SetCollisionB(GetX(),GetY(),12);//蔻(̓)o^
		yield;
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
	}

        task Tmain{

		Move;
		alternative(Level)
		case(1){//hard
			Shot1(24);
		}

		task Shot1(loops){
			let angle=0;
			loop{
				PlaySE(shoot13);
				SetShotDirectionType(PLAYER);
				loop(loops){
					CreateShotA(1,GetX,GetY,10);
					SetShotDataA(1, 0,4,angle,0,-0.1,0,69);
					SetShotDataA(1,40,4,    0,0,   0,2,69);
					FireShot(1);
					angle+=360/loops;
				}
				SetShotDirectionType(ABSOLUTE);
				loop(40){yield;}
			}
		}
        }

        task Move{
		let angle = GetAngle;//Gړpx
		let speed = GetSpeed;	     //Gx
		let Nspeed= GetSpeed;	     //Gړx
		SetAngle(90);
		SetAction(ACT_MOVE,40);
	      	loop(30){
			Nspeed-=speed/30;
			SetSpeed(Nspeed);
			yield;
		}
	      	loop(120){yield;}
		SetAngle(angle);
		SetAction(ACT_MOVE,500);
	      	loop(10){
			Nspeed+=1/10;
			SetSpeed(Nspeed);
			yield;
		}

      
        }
 
	

	@Finalize
	{
		if(BeVanished==true){return;}
		loop(2){CreateShotFromScript("I_Item",GetX+rand(-40,40),GetY+rand(-40,40),0,0,0,1);}
		loop(3){CreateShotFromScript("I_Item",GetX+rand(-60,60),GetY+rand(-60,60),0,0,0,0);}
		loop(8){
			CreateShotFromScript("TenItem",GetX+rand(40,-40),GetY+rand(40,-40),0,0,0,0);
		}
		loop(6){
			CreateShotFromScript("P_Item",GetX+rand(40,-40),GetY+rand(40,-40),0,0,0,0);
		}

	}
	
	@DrawLoop
	{//`
		SetTexture(Magic);
		SetGraphicRect(64,64,128,128);
		DrawGraphic(GetX(),GetY());

		DrawBoss(imgEnemy);
		DrawGraphic(GetX(),GetY());

	}
}