#東方弾幕風
#Title[全方位弾]
#Text[]
#ScriptVersion[2]

script_enemy_main {
 let img = "script\img\ExRumia.png";
 let name = "全方位弾";

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

 //以下タスク(マイクロスレッド)

 task TMain {
  yield;

  TMove;
  TShot; //何個足してもおｋ
 }

 task TMove {
  yield;
 }

 task TShot {
  let row = rand(1, 15);
  yield;

  loop {
   loop(15) { yield; }
   nway(15, GetX, GetY, 1, rand(0, 360) + row, RED31, 0);
   row = rand(1, 15);
  }
 }

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

 function nway(way, x, y, speed, angle, graphic, delay) {
  loop(way) {
   CreateShot01(x, y, speed, angle, graphic, delay);
   angle += 360 / way;
  }
 }

}