
script_enemy_main
{    
    let imgEnemy="script\DanMUku\Stage6\Image\chapeau.png";
    let count=-10;
    let type;
    let g;
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let a = 0;

 function Wait(let frames){
   loop(frames){yield;}
 }


   @Initialize
   {
      LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
      LoadGraphic(imgEnemy);
            SetLife(150);
	type = GetArgument[0];
	g = GetArgument[1];
   }

   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
          SetCollisionB(GetX, GetY-2*sin(GetAngle), 16);

	if (type==0) {
		if (count>0&&count%7==0) {
			PlaySE(munch);
			CreateShot02(GetX-18*cos(GetAngle), GetY-18*sin(GetAngle), 0, rand(GetAngle+100, GetAngle+260), rand(0.001, 0.004), 1, g, 10);
		}
	}

	if (type==1) {
		if (count<360) {
			SetAngle(GetAngle+1);
		}

		if (count>0&&count%10==0) {
			PlaySE(munch);
			CreateShot02(GetX-18*cos(GetAngle), GetY-18*sin(GetAngle), 0, GetAngle+a, 0.005, 1, g, 10);
			a-=30;
		}
	}

	if (type==-1) {
		if (count<360) {
			SetAngle(GetAngle-1);
		}

		if (count>0&&count%10==0) {
			PlaySE(munch);
			CreateShot02(GetX-18*cos(GetAngle), GetY-18*sin(GetAngle), 0, GetAngle+a, 0.005, 1, g, 10);
			a+=30;
		}
	}

	if (type==2) {
		if (count>0&&count%10==0) {
			CreateShot02(GetX-18*cos(GetAngle), GetY-18*sin(GetAngle), 0, rand(0,360), rand(0.001, 0.004), 2, g, 10);
		}

	}


count++;
yield;
   }
   @Finalize
   {
   }
   

   @DrawLoop
   {
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
	    SetGraphicAngle(0,0,GetAngle+90);
	    SetGraphicRect(0,0,67,41);

            DrawGraphic(GetX,GetY);


   }


}
