#TouhouDanmakufu
#Title[NSC02 Machin]
#Text[Seconde Non-spell de Machin]
#Image[]
#BGM[script\DanMUku\Stage1\Machin.mp3]
#Player[script\DanMUku\Joueur\KorA\KorHosik.txt, script\DanMUku\Joueur\KorB\KorB.txt, script\DanMUku\Joueur\KorC\KorC.txt]
#ScriptVersion[2]

script_enemy_main
{     
    let imgEnemy="script\DanMUku\Stage1\Image\Machin.png";
    let count=-100;
    let bullets = [];
    let a = 0;
    let obj_id=0;
    let circle =  [];
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let z = 0;
    let w = 0.5;

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

   @Initialize
   {
      LoadGraphic(imgEnemy);
      LoadMusic("script\DanMUku\Stage1\Machin.mp3");
      LoadSE(tir);
            SetLife(4000);
            SetTimer(30);
            SetInvincibility(60);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY - 100, 120);        
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(count==0)
{
a=GetAngleToPlayer;
PlaySE(tir);
loop(36)
{
CreateShot01(GetX, GetY, 2, a, BLUE01, 0);
Circle(GetX, GetY, 2, a+5, 0);
a+=10;
}
}
if(count==10)
{
SetMovePosition02(rand(GetCenterX+50, GetCenterX-50), rand(GetCenterY-150, GetCenterY-50), 40);
}
if(count==50)
{
count=-1;
}
count++;
yield;
   }
   @Finalize
   {
      DeleteGraphic(imgEnemy);
   }

   task Circle(x, y, v, angle, delay) {
      let obj_idd=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj_idd, x, y);
     Obj_SetAngle(obj_idd, angle);
     Obj_SetSpeed(obj_idd, v);
     ObjShot_SetGraphic(obj_idd, BLUE01);
     ObjShot_SetDelay  (obj_idd, delay);
     Wait(50);
     ObjShot_SetGraphic(obj_idd, GREEN01);
     Obj_SetSpeed(obj_idd, v*2);
     while(Obj_BeDeleted(obj_idd)==false) {
             yield;
      }
}

   @DrawLoop
   {
            PlayMusic("script\DanMUku\Stage1\Machin.mp3");
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
            SetGraphicRect(0,0,16*1.5,16*1.5);
            DrawGraphic(GetX,GetY+z);
     if(z==10){w=-0.5;}
     if(z==-10){w=0.5;}
z+=w;
	DrawText("Machin", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

}
