
#Title[夢月・通常弾幕6]
#Text[夢月・通常弾幕6]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main{
    #include_script".\Local.txt"
   let imgBOSS = csd~"img\dot_mugetu.png";
   let shotData = csd ~ "data_usershot.txt";
  let effect = csd ~ "img\circle.png";

   @Initialize{
           SetLife(2000);
      SetDamageRate(100,10);
           SetTimer(30);
           SetInvincibility(120);
         sgr(0,0);
      /*   SetMovePosition03(GetCenterX,GetClipMinY+120,20,20);*/
   SetX(cx); SetY(miny+140);
        SetAlpha(255);
           LoadGraphic(imgBOSS);
    LoadGraphic(effect);
          LoadUserShotData(shotData);
    Circle2(60);
           TMain;
    }

   @MainLoop{
    if(OnEvent){break;}
           SetCollisionA(GetX, GetY, 24);
           SetCollisionB(GetX, GetY, 18);

         yield;
       }

   @DrawLoop{
         SetTexture(imgBOSS);  
        DrawGraphic(GetX,GetY);
     }

    @Finalize{
        DeleteGraphic(imgBOSS);
        DeleteGraphic(effect);
     }
 
     task TMain{
    wait(30);
     Move;
          wait(90);
        Shot;
    loop{
   if(OnBomb){SetDamageRate(10,20);}
     else{SetDamageRate(100,10);}
    wait(1);
      }
    }

   task Shot{
     Shot1;
    task Shot1{
    let way = 36;
    loop{
      ascent(a in 0..way){
      let base = 360/way*a;
      let x = GetX;
      let y = GetY;
     ascent(v in 0..2){
       CreateShot02(x,y,6,base,-0.5,5-2*v,BLUE12,10);
          }
      }
      PlaySE(seshot1);
       wait(30);
         }
       }
    }

    task Move{
 loop{
   let f = 1;
  let r = rand_int(0,1);
 if(GetX < minx+64){r = 0;}
    else if(GetX > maxx-64){r = 1;}
    let x = GetX + 48*(-1)^r;
    let y = GetY + rand(-48,48);
    if(y < miny+48){y = miny+48;}
    else if(y > miny+160){y = miny+160;}
  /* if(GetX > x){sgr(2,1);}
   else if(GetX < x){sgr(2,3);}  */
    SetMovePosition03(x,y,15,f);
     wait(90);
      }
    }

    function offsetX(radius,angle){
           return radius * cos(angle);
     }

        function offsetY(radius,angle){
            return radius * sin(angle);
     }           

       function move(f){
          SetMovePosition02(rand(GetClipMinX+60,GetClipMaxX-60),GetY+rand(-20,20),f);
     }
            
        function sc(r,g,b){
             SetShotColor(r,g,b);
     }

  function sgr(a,b){SetGraphicRect(a*128,b*128,(a+1)*128,(b+1)*128);}

       function wait(w){
                loop(w){yield;}
       }
}