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(30);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
      sgr(0,5);	
          SetInvincibility(0);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),6);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100); 
   alternative(arg)
   case(31){
    CreateItem(ITEM_1UP,GetX,GetY);
     }
   others{
  loop(8){
    CreateItem(ITEM_SCORE,GetX,GetY);
    }
   }
             }
	}

         task Main{
             yield; 
       Shot;
     }

     task Shot{
    SetMovePosition02(GetX+rand(-64,64),miny+rand(64,128),60);
  wait(10);
  let x = GetX; let y = GetY;
  let color = 8; let delay = 0;
  let v = 2; let i = rand_int(0,1);
    loop(2){
  let base = rand(-180,180);
    ascent(a in 0..20){
   let angle = base+18*a;
     CreateShot02(x,y,6,angle,-0.1,v,color,delay); 
      } 
     PlaySE(seshot1);
     wait(30);
    }
  SetMovePosition02(GetX+rand(-64,64),miny-30,60);
   loop(2){
  let base = rand(-180,180);
    ascent(a in 0..20){
   let angle = base+18*a;
     CreateShot02(x,y,6,angle,-0.1,v,color,delay); 
      } 
     PlaySE(seshot1);
     wait(30);
    }
   wait(60);
   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;}
       }
}