script_enemy_main
{    
    let imgEnemy="script\DanMUku\Stage5\Image\maskass.png";
    let count=-50;
    let angle = 0;
	let dir = 1;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
	let couleur = 73;
    let score = true;

   @Initialize
   {
	  LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
      LoadGraphic(imgEnemy);
      LoadSE(tir);
	  LoadSE(munch);
            SetLife(400); 
		if ( GetArgument<50) {
			dir=-1;
		} 
		alternative(GetArgument)
		case(49) {
			couleur = 75;
		}
		case(98) {
			couleur = 74;
		}
		case(149) {
			couleur = 77;
		}
   }

	function cloche(angle) {
		let id = 0;
		loop(5) {
			CreateShotA(id, GetX, GetY, 0);
			SetShotDataA(id, 0, 2.5+rand(0,1), 2*angle+rand(80,100), -angle/40, -0.02, 1, couleur);
			SetShotDataA(id, 60, NULL, NULL, 0, 0.05, 4, couleur);
			FireShot(id);
			id++;
		}
		PlaySE(munch);

	}

   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
if(count%10==0)
{
	if (angle==40) {
		dir=-1;
		if (GetY<GetCenterY+20) {
			cloche(angle);
		}
	}
	if (angle==-40) {
		dir=1;
		if (GetY<GetCenterY+20) {
			cloche(angle);
		}
	}
	angle = angle+5*dir;
	SetAngle(90-angle);
}

if (GetY>GetClipMaxY+40) {
	score = false;
	VanishEnemy;
}

count++;
yield;
   }
   @Finalize
   {
	if (GetX>0&&GetY>0&&GetX<448&&GetY<480&&GetCommonData("maskass")>=0) {
		SetCommonData("maskass", GetCommonData("maskass")+1);
		if (GetCommonData("maskass")==80) {
			SetCommonData("U", true);
		}
	}

	if (score) {
		loop(4)
		{
			CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
		}
	}
}
   
   @DrawLoop
   {
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
            SetGraphicRect(8, GetArgument(), 32, GetArgument()+37);
			SetGraphicAngle(0, 0, angle);
            DrawGraphic(GetX,GetY);
   }

}
