#e
#Title[JuJAPAoXɂ-Lunatic-v]
#Text[G@́uXǏPv]
#ScriptVersion[2]
#PlayLevel[Lunatic]
#Player[FREE]

script_enemy_main {
 let img = "script\img\ExRumia.png";
 let name = "JuJAPAoXɂ-Lunatic-v";

 @Initialize {
  CutIn(KOUMA, name, "", 0, 0, 0, 0);
  SetX(GetCenterX);
  SetY(GetCenterY - 60);
  SetLife(7000);
  SetScore(1000000);

  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);
 }

 task TMain {
  yield;

  TLaser;
  TMove;
  TShot;
  TRain;
 }

 task TLaser {
  yield;

  loop {
   loop(10) { yield; }
   CreateLaser01(rand(GetClipMinX, GetClipMaxX), GetClipMinY, rand(0.5, 2), 90, rand(80, 120), 5, BLUE11, 0);
  }
 }

 task TMove {
  yield;

  loop {
   loop(90) { yield; }
   moveToPlayer(rand(-400, 400), rand(-10, 10), 100, GetClipMinX, GetClipMinY, GetClipMaxX, GetClipMaxY);
  }
 }

 task TShot {
  yield;

  loop {
   loop(50) { yield; }
   CreateShot01(GetX, GetY, 1, rand(0, 180), BLUE03, 0);
  }
 }

 task TRain {
  yield;

  loop {
   loop(10) { yield; }
   CreateShotA(1, GetX, GetY, 0);
   SetShotDataA(1, 0, rand(1, 2), rand(-135, -45), 0, 0, 2, AQUA11);
   SetShotDataA(1, 90, rand(1, 2), 90, 0, 0, 2, AQUA11);
   FireShot(1);
  }
 }

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

  x = GetX + xMove;
  if(x < left) {
   x = left;
  }
  else if(right < x) {
   x = right;
  }

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

  SetMovePosition02(x, y, frame);
 }

}