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(100);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
      sgr(0,0);	
          SetInvincibility(0);
               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); 
  let radius = rand(0,0);
  let angle = rand(-180,180);
   loop(8){
  CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
       rank += 1;
             }
   SetCommonDataEx("","PlayRank",rank);
	}

         task Main{
             yield; 
   alternative(arg)
 case(0,3){SetMovePosition02(GetX,miny+60,60);}
 case(1,4){SetMovePosition02(minx+60,GetY,60);}
 case(2,5){SetMovePosition02(maxx-60,GetY,60);}
       Shot;
     }

     task Shot{
    wait(60);
  let color = RED01;
  let color2 = RED04;
  let delay = 10;
 alternative(arg)
 case(0,1,2){
  ascent(b in 0..6){
  let v = 2+b;
  ascent(a in 0..3){
   let angle = GetAngleToPlayer+6*(a-1);  
 CreateShot01(GetX,GetY,v,angle,color2,delay);
    }
   ascent(c in 0..2){
   let angle = GetAngleToPlayer+6*(c-1)+3;  
 CreateShot01(GetX,GetY,v+0.75,angle,color2,delay);
     }
    }
   }
  others{
    ascent(b in 0..6){
  let v = 2+0.5*b;
  ascent(a in 0..7){
   let angle = GetAngleToPlayer+6*(a-3);  
 CreateShot01(GetX,GetY,v,angle,color,delay);
    }
   ascent(c in 0..6){
   let angle = GetAngleToPlayer+6*(c-3)+3;  
 CreateShot01(GetX,GetY,v+0.35,angle,color,delay);
     }
    }
   }
  PlaySE(seshot3);
  wait(30);
   SetAngle(GetAngleToPlayer);
  ascent(v in 0..60){
   SetSpeed(v*0.1);
   wait(1);
  }
    wait(300);
   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;}
       }
}