#東方弾幕風
#Title[クルクル〜移動ver]
#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;
  TShot2; //何個足してもおｋ
 }

 task TMove {
  yield;
 }

 task TShot {
  let angle = 0;
  let xMove = 1;
  let pet = 0;
  yield;

  loop {
   loop(5) { yield; }
   CreateShot01(GetX - xMove, GetY, 1, angle, RED11, 5);
   angle += 16.5;

   pet += 1;
   if(pet < 200) {
    xMove += 1;
   }
   if(pet >= 200) {
    xMove -= 1;
   }
   if(pet > 400) {
    pet = 0;
   }
  }
 }

 task TShot2 {
  let angle = 0;
  let xMove = 1;
  let pet = 0;
  yield;

  loop {
   loop(5) { yield; }
   CreateShot01(GetX + xMove, GetY, 1, angle, BLUE11, 5);
   angle -= 11.5;

   pet += 1;
   if(pet < 200) {
    xMove += 1;
   }
   if(pet >= 200) {
    xMove -= 1;
   }
   if(pet > 400) {
    pet = 0;
   }
  }
 }

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

}