script_enemy_main
{    
    let imgEnemy="script\DanMUku\Stage4\Image\Lakitu.png";
    let count=-50;
    let angle=0;
    let d = 90;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";

   @Initialize
   {
      LoadGraphic(imgEnemy);
      LoadSE(tir);
      LoadSE(munch);
            SetLife(800); 
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
if(count==0){
		SetSpeed(0);
	}
if(count%3==0&&count>=0&&count<1000){
	CreateShot01(GetX, GetY, 6, d+rand(-5,5), RED01, 0);
	CreateShot01(GetX, GetY, 6, d+50+rand(-5,5), WHITE01, 0);
	CreateShot01(GetX, GetY, 6, d-50+rand(-5,5), WHITE01, 0);
	if(angle==0){
		d++;
	}else{
		d--;
	}
}
if(count%9==0&&count>=0&&count<1000){PlaySE(tir);}
if(d==100){angle=1;}
if(d==80){angle=0;}
if(count==1000){
	SetSpeed(1);
}
count++;
yield;
   }
   @Finalize
   {
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10)); 

	if (GetX>0&&GetY>0&&GetX<448&&GetY<480&&GetCommonData("lakitu")>=0) {
		SetCommonData("lakitu", GetCommonData("lakitu")+1);
		if (GetCommonData("lakitu")==5) {
			SetCommonData("N", true);
		}
	}
 
DeleteEnemyShotToItem(CHILD);
}
   
   @DrawLoop
   {
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
            SetGraphicRect(0, 0, 30, 40);
            DrawGraphic(GetX,GetY);
if(GetArgument==1)
{
SetGraphicAngle(180, 0, 0);
}
else
{
SetGraphicAngle(0, 0, 0);
}
   }

}
