
script_enemy_main
{    

    let count=-100;
    let difficulties = 0;
    let bg = "script\DanMUku\Image\bonusroom.png";
    let bonus = "script\DanMUku\Image\bonus.png";
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let timer = 0;


   @Initialize
   {
      LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
      LoadGraphic(bg);
      LoadGraphic(bonus);
      LoadMusic("script\DanMUku\Musique\bonus.mp3");
      LoadMusic("script\DanMUku\Musique\bonusclear.mp3");
      LoadSE(tir);
      LoadSE(munch);
	LastSpell;
	//PlayMusic("script\DanMUku\Musique\bonus.mp3");
            SetLife(8500);
            SetTimer(120);
            SetInvincibility(100);
            SetEnemyMarker(false);
            SetScore(0);
   }
   
 function Wait(let frames){
   loop(frames){yield;}
 }

   @MainLoop
   {

	if(count>0&&count<2400&&count%5==0){
		CreateShot01(rand(GetClipMinX, GetClipMaxX), 0, 1, 90, 81, 0);
	}

	if(count>1200&&count%20==0){
		CreateShot01(GetClipMinX, rand(GetClipMinY, GetCenterY+150), 1, 45, 81, 0);
		CreateShot01(GetClipMaxX, rand(GetClipMinY, GetCenterY+150), 1, 135, 81, 0);		
	}

	if(count>2400&&count%4==0){
		CreateShot01(rand(GetClipMinX, GetClipMaxX), 0, 2, 90, 81, 0);
	}

	if(count>3600&&count%20==10){
		CreateShot01(GetClipMinX, rand(GetClipMinY, GetCenterY+150), 1, 45, 81, 0);
		CreateShot01(GetClipMaxX, rand(GetClipMinY, GetCenterY+150), 1, 135, 81, 0);
	}

	if(count>4800&&count%30==0){
		CreateShot01(GetClipMinX, rand(GetClipMinY, GetCenterY-50), 1, 0, 81, 0);
		CreateShot01(GetClipMaxX, rand(GetClipMinY, GetCenterY-50), 1, 180, 81, 0);
	}

timer=GetTimer;

count++;
yield;
   }
   @Finalize
   {
	DeleteMusic("script\DanMUku\Musique\bonus.mp3");
	if (GetArgument==5) {
		if(timer==0){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY); 
		}
		if(timer<20){
			CreateItem(ITEM_1UP, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<40){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<60){
			CreateItem(ITEM_1UP, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<90){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY);  
		}
	}
	if (GetArgument==4) {
		if(timer==0){
			CreateItem(ITEM_1UP, rand(GetX-20, GetX+20), GetClipMinY); 
		}
		if(timer<20){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<40){
			CreateItem(ITEM_1UP, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<60){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY);  
		}
	}
	if (GetArgument==3) {
		if(timer==0){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY); 
		}
		if(timer<20){
			CreateItem(ITEM_1UP, rand(GetX-20, GetX+20), GetClipMinY);  
		}
		if(timer<40){
			CreateItem(ITEM_BOMB, rand(GetX-20, GetX+20), GetClipMinY);  
		}
	}


	loop(GetArgument*((120-timer)/5) ){
		CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetClipMinY+20, GetClipMinY+50));  
	}

   }

   @DrawLoop
   {

            SetTexture(bg);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 50000, 50000);

            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX, GetCenterY-50);


			SetTexture(bonus);
		    SetRenderState(ALPHA);
		    SetAlpha(255);
		    SetGraphicRect(0, 0, 150, 80);
			SetGraphicScale(1,1);
            		SetGraphicAngle(0, 0, 0);
			DrawGraphic(GetCenterX, GetCenterY-50);


	DrawText("Bonus", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

}
