script_enemy_main{
        let csd = GetCurrentScriptDirectory;
	let Enemy=csd~"img\dot-kaze-ti.png";
        let shotData = csd ~ "data_usershot.txt";
        let gx = GetX;
        let gy = GetY;
        let gspeed = GetSpeed;
        let gangle = GetAngle;
        let arg = GetArgument;
        let se1 = csd~ "bgm\tm2_laser001.wav";
	@Initialize
	{
            if(GetPlayerType == REIMU_A){SetLife(500);}
            else{SetLife(500);}
            SetDamageRate(0,0);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
		SetGraphicRect(60,130,100,160);	
          LoadSE(se1);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),12);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100); 
              DeleteEnemyShotToItem(ALL);
           loop(16){ 
           CreateItem(ITEM_SCORE,GetX+offsetX(32,rand(-180,180)),GetY+offsetY(32,rand(-180,180)));
           }
             }
	}

         task Main{
             yield; 
          wait(60);
       Laser;
    /*   Move; */
     }

     task Laser{
        let x = GetX;
        let y = GetY;
         let angle = 90;
         let length = 600;
         let width = 10;
         let color = 192;
          let delay = 180;
         CreateLaserA(0,x,y,0,width,color,delay); 
         SetLaserDataA(0,0,angle,0,length/180,0,0);
         SetLaserDataA(0,180,NULL,0,0,0,0);
         SetShotKillTime(0,360);
        FireShot(0);
          PlaySE(se1); 
        VanishEnemy;
       }

     task Move{
           SetSpeed(0);
           SetAngle(gangle);
      }
         

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

       sub setGraphicStop  { SetGraphicRect( 40,  20, 80, 100); }

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