#e
#Title[ueh[-v[h-v]
#Text[gF[~AALX]
#ScriptVersion[2]

script_enemy_main {
 let img = "script\img\ExRumia.png";
 let name = "ueh[-v[h-v";

 @Initialize {
  CutIn(KOUMA, name, "", 0, 0, 0, 0);
  SetX(GetCenterX);
  SetY(GetCenterY - 120);
  SetLife(5000);
  SetScore(1000000);
  SetTimer(99);

  LoadGraphic(img);
  SetTexture(img);
  SetGraphicRect(64, 0, 128, 64);

  TMain;
 }

 @MainLoop {
  SetCollisionA(GetX, GetY, 24);
  SetCollisionB(GetX, GetY, 24);

  yield;
 }

 @DrawLoop {
  DrawGraphic(GetX, GetY);
 }

 @Finalize {
  DeleteGraphic(img);
 }

 //ȉ^XN(}CNXbh)

 task TMain {
  yield;

  TMove;
  TRumia;
  TKisume; //Ă
 }

 task TMove {
  yield;

  loop { //Ƃ͂
   loop(120) { yield; }
   randomMove(rand(-80, 80), rand(-80, 80), 120, GetClipMinX, GetClipMinY, GetClipMaxX, GetCenterY - 60);
  } //܂ł΂I
 }

 task TRumia {
  let addven = 0;
  yield;

  loop {
   loop(120) { yield; }

   loop(8) {
    loop(8) {
     CreateShot02(GetX, GetY, 1.5, atan2(GetPlayerY - GetY, GetPlayerX - GetX), addven, 10, RED01, 10);
     addven += 0.005;
    }
    wait(12);
    addven = 0;
   }

  }
 }

 task TKisume {
  let angle = 0;
  let way = 8;
  yield;

  loop {
   loop(20) { yield; }

   loop(way) {
    CreateShot01(GetX, GetY, 1, angle, PURPLE21, 0);
    angle += 360 / way + 90 / way;
   }

  }
 }

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

 function randomMove(xMove, yMove, frame, left, top, right, bottom) {
  let x;
  let y;

  x = GetX + xMove;

  if(x < left) {
   x = left;
  }
  if(right < x) {
   x = right;
  }

  y = GetY + yMove;
  if(y < top) {
   y = top;
  }
  else if(bottom < y) {
   y = bottom;
  }

  SetMovePosition02(x, y, frame);
 }

}