
script_enemy_main
{    

    let count=-100;
    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;
    let angle=270;
    let a=0;
    let colour = [38, 50, 48, 43, 40];
    let changement = 0;
    let diff=50;

   @Initialize
   {
      LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
      LoadGraphic(bg);
      LoadGraphic(bonus);
      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%100<diff){
		let i = 0;
		loop(5){
			CreateShot01(GetCenterX+cos(angle)*200, GetCenterY+sin(angle)*200, 2*(diff/100.0), a, colour[i], 30);
			a+=2*360/5;
			angle+=360/5;
			i++;
		}
	}

	if (count%2000==0){
		changement=-1;
	}
	if (count%2000==1000){
		changement=1;
	}

	if (count==2000) {
		diff=60;
	}

	if (count==4000) {
		diff=70;
	}

	if (count==6000) {
		diff=80;
	}

	
	angle+=changement;

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



}
