script_enemy_main
{//Enemy03
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Animation=0;
	let AnimationA=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
	let angle=0;
	let imgAngle=0;
	let imgAlpha=255;
	let deathse=csd~"se\DEATH.wav";
	let Flag=false;
	let shotseA=csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(170);
        SetScore(10);
        SetDamageRate(0,0);
        SetInvincibility(50);
        SetX(GetX);
        SetY(0);
	LoadGraphic(imgBoss2);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
	SetMovePosition03(GetX,150,10,4);
        TAnime;
	TAnime2;
	}

	@MainLoop {
	if(GetLife<=100&&Flag==false){
			SetMovePosition01(GetX,GetY+100,1);
			PlaySE(deathse);
			TAnime3;
			Flag=true;
			}
	if(Flag==true){
		imgAngle+=7;
		imgAlpha-=5;
		if(imgAlpha<=0){AddLife(-1000);}
		} else {
		SetCollisionA(GetX(),GetY(),10);
		SetCollisionB(GetX(),GetY(),10);
		}
        	SetDamageRate(100,100);
	if(count==400&&Flag==false){
		TAnime2;
		SetMovePosition01(GetX,-20,2);
		}
	if(count>=100&&Flag==false){
        	SetShotDirectionType(ABSOLUTE);
		angle=rand_int(0,36)*10;
		PlaySE(shotseA);
		let i=0;
		while(i<3)
		{
			let shotA=0;
			CreateShotA(shotA,GetX+cos(angle+i*120)*10,GetY+sin(angle+i*120)*10,5);
			SetShotDataA(shotA,0,5,angle+i*120,0,-0.05,3,126);
			FireShot(shotA);
			i+=1;
			}
		}
	if(count>=200&&count%200==0){
		PlaySE(shotseA);
		let i=0;
		while(i<15){
        		SetShotDirectionType(PLAYER);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*24-6,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.7,i*24-4,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.9,i*24-2,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,2.1,i*24,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,2.3,i*24+2,0,0,0,2);
			FireShot(shotA);
			i=i+1;
			}
		}
	if(count>=200&&count%200==100){
		PlaySE(shotseA);
		let i=0;
		while(i<15){
        		SetShotDirectionType(PLAYER);
			let shotA=0;
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.5,i*24+6,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.7,i*24+4,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,1.9,i*24+2,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,2.1,i*24,0,0,0,2);
			FireShot(shotA);
			CreateShotA(shotA,GetX(),GetY(),0);
			SetShotDataA(shotA,0,2.3,i*24-2,0,0,0,2);
			FireShot(shotA);
			i=i+1;
			}
		}
        if(count>=100&&GetX<-10||GetX>458||GetY>490||GetY<-10)
        	{
        	VanishEnemy();
        	}
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,imgAngle);
		SetAlpha(imgAlpha);
		if(Flag==true){SetGraphicRect(193,64,254,127);}
		else if(int(GetSpeedX())==0){SetGraphicRect(Animation*64,64,63+Animation*64,127);}
		else if(GetSpeedX()>0){SetGraphicRect(AnimationA*64+128,129,AnimationA*64+191,191);}
		else if(GetSpeedX()<0){SetGraphicRect(AnimationA*64,129,AnimationA*64+63,191);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
		if(!BeVanished){
			loop(5){
				CreateItem(ITEM_SCORE,GetX+rand(-20,20),GetY+rand(-20,20));
			}
		}
        } 

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
    	task TAnime2{
			AnimationA=0;
        		loop(10){yield;}
			AnimationA=1;
        		loop(80){yield;}
			AnimationA=0;
        		loop(10){yield;}
		}
    	task TAnime3{
			Animation=4;
		}
}