let b ="script\DanMUku\Image\b.png";
let o ="script\DanMUku\Image\o.png";
let n ="script\DanMUku\Image\n.png";
let u ="script\DanMUku\Image\u.png";
let s="script\DanMUku\Image\s.png";
let bonus="script\DanMUku\Image\bonus.png";
let gotbonus=false;
let q = 0;
let boss=false;
let count=0;

let goombaN = "script\DanMUku\Stage1\ParagoombaN.txt";
let goombaB = "script\DanMUku\Stage1\ParagoombaB.txt";
let goombaR = "script\DanMUku\Stage1\ParagoombaR.txt";
let goombaM = "script\DanMUku\Stage1\ParagoombaM.txt";

#include_script "script\DanMUku\Wait.txt";

 function Ini1() {
	LoadGraphic("script\DanMUku\Stage1\Image\Background1.png");
	PlayMusic("script\DanMuku\Stage1\Stage1.mp3");
	SetCommonData("StageFini", false);
	SetCommonData("B", false);
	SetCommonData("O", false);
	SetCommonData("N", false);
	SetCommonData("U", false);
	SetCommonData("S", false);
	SetCommonData("nobonus", false);
	SetCommonData("goomba", 0);
	LoadGraphic(b);
	LoadGraphic(o);
	LoadGraphic(n);
	LoadGraphic(u);
	LoadGraphic(s);
	LoadGraphic(bonus);
	stage1;
  }


 function BG1() {
           SetTexture("script\DanMUku\Stage1\Image\Background1.png");
            SetRenderState(ALPHA);
            SetGraphicRect(0, 0, 384, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX, GetCenterY);
		if (boss==false) {
			q-=6;
		}

	if(GetCommonData("B")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(b);
            SetGraphicRect(0,0,14,21);
            DrawGraphic(GetClipMaxX-90,GetClipMaxY-10);
	}
	if(GetCommonData("O")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(o);
            SetGraphicRect(0,0,19,20);
            DrawGraphic(GetClipMaxX-70,GetClipMaxY-10);
	}
	if(GetCommonData("N")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(n);
            SetGraphicRect(0,0,15,20);
            DrawGraphic(GetClipMaxX-50,GetClipMaxY-10);
	}
	if(GetCommonData("U")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(u);
            SetGraphicRect(0,0,15,21);
            DrawGraphic(GetClipMaxX-30,GetClipMaxY-10);
	}
	if(GetCommonData("S")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(s);
            SetGraphicRect(0,0,16,23);
            DrawGraphic(GetClipMaxX-10,GetClipMaxY-10);
	}
	if(GetCommonData("nobonus")){
		SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(b);
            SetGraphicRect(0,0,14,21);
            DrawGraphic(GetCenterX-170,GetCenterY-100);
		DrawText("Defeat the mid-boss without losing a life.",GetCenterX-150,GetCenterY-110,16,255);

		SetTexture(o);
            SetGraphicRect(0,0,19,20);
            DrawGraphic(GetCenterX-170,GetCenterY-60);
		DrawText("Kill the bonus Shy Guy.",GetCenterX-150,GetCenterY-70,16,255);

		SetTexture(n);
            SetGraphicRect(0,0,15,20);
            DrawGraphic(GetCenterX-170,GetCenterY-20);
		DrawText("Defeat 50 goombas.",GetCenterX-150,GetCenterY-30,16,255);

		SetTexture(u);
            SetGraphicRect(0,0,15,21);
            DrawGraphic(GetCenterX-170,GetCenterY+20);
		DrawText("Capture Within a deep forest",GetCenterX-150,GetCenterY,16,255);
		DrawText("'Stories of flying Munchers'.",GetCenterX-150,GetCenterY+20,16,255);

		SetTexture(s);
            SetGraphicRect(0,0,16,23);
            DrawGraphic(GetCenterX-170,GetCenterY+60);
		DrawText("Finish Lunarian sign 'Moonsong'",GetCenterX-150,GetCenterY+40,16,255);
		DrawText("with 5 seconds or fewer left.",GetCenterX-150,GetCenterY+60,16,255);
	}

	if(gotbonus&&count%60<40){
			SetTexture(bonus);
		    SetRenderState(ALPHA);
		    SetAlpha(255);
		    SetGraphicRect(0, 0, 150, 80);
			SetGraphicScale(1,1);
            		SetGraphicAngle(0, 0, 0);
			DrawGraphic(GetCenterX, GetCenterY-50);
	}

 }

 task stage1{
Wait(60);
CreateEnemyFromFile(goombaN, 300, GetClipMinY, 1, 90, 0);
Wait(30);
CreateEnemyFromFile(goombaN, 310, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 290, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 305, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 295, GetClipMinY, 1, 90, 1);
Wait(90);
CreateEnemyFromFile(goombaN, 100, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 110, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 90, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 105, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 95, GetClipMinY, 1, 91, 1);
Wait(150);
CreateEnemyFromFile(goombaB, GetCenterX-100, GetClipMinY, 1, 60, 2);
CreateEnemyFromFile(goombaB, GetCenterX+100, GetClipMinY, 1, 120, 2);
Wait(50);
CreateEnemyFromFile(goombaB, GetCenterX-110, GetClipMinY, 1, 65, 2);
CreateEnemyFromFile(goombaB, GetCenterX+95, GetClipMinY, 1, 125, 2);
Wait(50);
CreateEnemyFromFile(goombaB, GetCenterX-90, GetClipMinY, 1, 70, 2);
CreateEnemyFromFile(goombaB, GetCenterX+105, GetClipMinY, 1, 110, 2);
Wait(160);
CreateEnemyFromFile(goombaR, GetCenterX, GetClipMinY, 1, 90, 3);
Wait(100);
CreateEnemyFromFile(goombaN, GetClipMaxX, 100, 2, 180, 1);
Wait(20);
CreateEnemyFromFile(goombaN, GetClipMaxX, 100, 2, 180, 1);
Wait(20);
CreateEnemyFromFile(goombaN, GetClipMaxX, 100, 2, 180, 1);
Wait(20);
CreateEnemyFromFile(goombaN, GetClipMaxX, 100, 2, 180, 1);
Wait(20);
CreateEnemyFromFile(goombaN, GetClipMaxX, 100, 2, 180, 1);
Wait(20);
CreateEnemyFromFile(goombaB, GetClipMinX, 100, 1, 30, 2);
Wait(30);
CreateEnemyFromFile(goombaB, GetClipMinX, 120, 1, 20, 2);
Wait(30);
CreateEnemyFromFile(goombaB, GetClipMinX, 100, 1, 40, 2);
CreateEnemyFromFile(goombaB, GetClipMinX, 150, 1, 10, 2);
Wait(60);
CreateEnemyFromFile(goombaR, GetCenterX-150, GetClipMinY, 1, 90, 3);
CreateEnemyFromFile(goombaR, GetCenterX+150, GetClipMinY, 1, 90, 3);
Wait(600);
 CreateEnemyBossFromFile("script\DanMUku\Stage1\MachinMid.txt", GetCenterX, GetClipMinY, 0, 0, 0);
WaitForZeroEnemy;
Wait(60);
CreateEnemyFromFile(goombaN, 300, GetClipMinY, 1, 90, 0);
Wait(30);
CreateEnemyFromFile(goombaN, 310, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 290, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 305, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 295, GetClipMinY, 1, 90, 1);
CreateEnemyFromFile(goombaR, GetCenterX-150, GetClipMinY, 1, 90, 3);
CreateEnemyFromFile(goombaR, GetCenterX+150, GetClipMinY, 1, 90, 3);
Wait(90);
CreateEnemyFromFile(goombaN, 100, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 110, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 90, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 105, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 95, GetClipMinY, 1, 91, 1);
Wait(150);
CreateEnemyFromFile(goombaM, GetCenterX-150, GetClipMinY, 0.5, 90, 0);
CreateEnemyFromFile(goombaM, GetCenterX+150, GetClipMinY, 0.5, 90, 1);
Wait(100);
CreateEnemyFromFile(goombaB, GetCenterX-100, GetClipMinY, 1, 60, 2);
CreateEnemyFromFile(goombaB, GetCenterX+100, GetClipMinY, 1, 120, 2);
CreateEnemyFromFile("script\DanMUku\Stage5\1UPMaskass.txt", GetClipMaxX, 90, 2, 130, "O");
Wait(50);
CreateEnemyFromFile(goombaB, GetCenterX-110, GetClipMinY, 1, 65, 2);
CreateEnemyFromFile(goombaB, GetCenterX+95, GetClipMinY, 1, 125, 2);
Wait(50);
CreateEnemyFromFile(goombaB, GetCenterX-90, GetClipMinY, 1, 70, 2);
CreateEnemyFromFile(goombaB, GetCenterX+105, GetClipMinY, 1, 110, 2);
Wait(200);
CreateEnemyFromFile(goombaN, 300, GetClipMinY, 1, 90, 0);
Wait(30);
CreateEnemyFromFile(goombaN, 310, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 290, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 305, GetClipMinY, 1, 90, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 295, GetClipMinY, 1, 90, 1);
CreateEnemyFromFile(goombaM, GetCenterX-180, GetClipMinY, 0.5, 90, 1);
CreateEnemyFromFile(goombaM, GetCenterX+180, GetClipMinY, 0.5, 90, 1);
CreateEnemyFromFile(goombaM, GetCenterX, GetClipMinY, 0.5, 90, 0);
Wait(90);
CreateEnemyFromFile(goombaN, 100, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 110, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 90, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 105, GetClipMinY, 1, 91, 1);
Wait(30);
CreateEnemyFromFile(goombaN, 95, GetClipMinY, 1, 91, 1);
Wait(60);
CreateEnemyFromFile(goombaR, GetCenterX-150, GetClipMinY, 1, 90, 3);
CreateEnemyFromFile(goombaR, GetCenterX+150, GetClipMinY, 1, 90, 3);
Wait(600);
ForbidShot(true);
Wait(100);
boss=true;
 CreateEnemyBossFromFile("script\DanMUku\Stage1\Machin.txt", GetCenterX, GetClipMinY, 0, 0, 0);
Wait(10);
ForbidShot(false);
WaitForZeroEnemy;
AddScore(1000000);
Wait(100);
boss=false;

	SetCommonData("nobonus", true);
	Wait(300);
	SetCommonData("nobonus", false);

	let numberBonus = 0;
	ascent (i in 0..5) {
		if (GetCommonData(["B", "O", "N", "U", "S"][i])) {
			numberBonus++;
		}
	}

	if (numberBonus>=3) {
		gotbonus= true;
		count=0;
		PlayMusic("script\DanMUku\Musique\bonus.mp3");
		Wait(200);
		CreateEnemyBossFromFile("script\DanMUku\Stage1\Bonus1.txt", GetCenterX, GetClipMinY, 0, 0, numberBonus);
		gotbonus=false;
		WaitForZeroEnemy;
		Wait(100);
	}


SetCommonData("StageFini", true);
 }
