script_enemy_main{
      #include_script".\Local.txt"
	let Enemy=csd~"img\dot_yousei.png";
        let shotData = csd ~ "data_usershot.txt";
   let arg = GetArgument;
 let effect = csd ~ "img\circle.png";
	@Initialize
	{

         SetLife(50);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
      sgr(0,0);	
          SetInvincibility(110);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),6);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
   let rank = GetCommonDataDefaultEx("","PlayRank",0);
         if(!BeVanished){
             AddScore(100); 
  loop(2){
  let radius = rand(0,48);
  let angle = rand(-180,180);
   loop(8){
  CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
   }
  loop(8){
    let radius = rand(0,48);
  let angle = rand(-180,180);
   CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
       rank += 1;
             }
   SetCommonDataEx("","PlayRank",rank);
	}

         task Main{
             yield; 
       Shot;
 
     }

     task Shot{
   SetMovePosition02(GetX,GetY+90,90);
    wait(90);
  let rank = GetCommonDataDefaultEx("","PlayRank",0);
   let v = 0.6;
  let angle = rand(-180,180);
   ascent(a in 0..8){
     ascent(b in 0..18){
      CreateShot01(GetX,GetY,v+0.3*a,angle+20*b+3*a,BLUE01,60);
       }
      }
  wait(20);
   ascent(a in 0..8){
     ascent(b in 0..18){
      CreateShot01(GetX,GetY,v+3.3,angle+7+20*b-3*a,BLUE01,40);
       }
   PlaySE(seshot3);
    wait(5);
      }
   wait(30);
   SetAngle(90);
   SetSpeed(1);
    wait(420);
   VanishEnemy; 
    }

     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*32,b*32,(a+1)*32,(b+1)*32);}

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