

task stage_stage01(){

	PlayMusic(bgm_01);

//sequence 1--------------------------------------


	//stage_Danger(150,150);

	m_practice_text = "Sequence 1/5";

	loop(100){yield;}

/*
	stage_Danger(GetCenterX()-30, GetCenterY()-60);
	stage_Danger(GetCenterX()+30, GetCenterY()-60);
	stage_Danger(GetCenterX()-30, GetCenterY()-90);
	stage_Danger(GetCenterX()+30, GetCenterY()-90);
	stage_Danger(GetCenterX()-30, GetCenterY()-120);
	stage_Danger(GetCenterX()+30, GetCenterY()-120);
	loop(100){yield;}
	CreateEnemyBossFromFile(system_GetEnemyPath("TYPE_BOSS01"), GetCenterX(), 00, 0, 0, 0);	

return;
*/

	loop(5){
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()-120, 0, 0, 0, [01, GetCenterX()-120, 80, 0.8, 80]);	
		loop(25){yield}
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()-80, 0, 0, 0, [01, GetCenterX()-80, 80, 0.8, 80] );	
		loop(25){yield}
	}

	loop(120){yield;}

	loop(5){
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()+120, 0, 0, 0, [01, GetCenterX()+120, 80, 0.8, 100]);	
		loop(25){yield}
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()+80, 0, 0, 0, [01, GetCenterX()+80, 80, 0.8, 100] );	
		loop(25){yield}
	}

	loop(120){yield;}


	loop(5){
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()-120, 0, 0, 0, [02, GetCenterX()-120, 80, 1.8, 100]);	
		loop(25){yield}
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()-80, 0, 0, 0, [02, GetCenterX()-80, 80, 1.8, 100] );	
		loop(25){yield}
	}

	loop(120){yield;}


	loop(5){
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()+120, 470, 0, 0, [02, GetCenterX()+120, 420, 1.8, 100]);	
		loop(25){yield}
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetCenterX()+80, 470, 0, 0, [02, GetCenterX()+80, 420, 1.8, 100] );	
		loop(25){yield}
	}

	stage_StopGameover();



//sequence 2--------------------------------------

	m_practice_text = "Sequence 2/5";

	loop(120){yield;}

	stage_Danger(90, 80);
	stage_Danger(370, 420);
	loop(70){ yield }

	loop(10){
		local{
			let x = rand(50,120);
			let y = rand(50,120);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), 450, 0, 0, 0, [01, x, y, 1.6, rand(0,90)]);	
		}
		local{
			let x = rand(340,400);
			let y = rand(390,450);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), 0, 460, 0, 0, [01, x, y, 1.6, rand(180,270)] );	
		}
		loop(15){yield}
	}


	loop(140){yield;}

	loop(70){ yield; }

	ascent(i in 0..8){
		local{
			let y = 440 - 350*(i/7);
			stage_CreateEnemyWithDanger(90, y, 70, "TYPE01B", 90, 0, 0, 0, [03, 90, y, 1.6, 0]);
		}
		local{
			let y = 115 + 350*(i/7);
			stage_CreateEnemyWithDanger(370, y, 70, "TYPE01B", 370, 470, 0, 0, [03, 370, y, 1.6, 180] );	
		}
		loop(15){yield}
	}

	loop(200){yield;}


	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)-20;
		stage_CreateEnemyWithDanger(x+20, 420, 80,"TYPE02B", x, 480, 0.8, 300,  [01, x+20, 420, 4, 60] );	
		loop(20){yield}
	}
	loop(30){yield;}

	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)-20;
		loop(20){yield}
		stage_CreateEnemyWithDanger(x+20, 80, 80,"TYPE02B", x, 0, 0.8, 60, [01, x+20, 80, 4, 300] );
	}
	loop(80){yield;}

	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)+20;
		stage_CreateEnemyWithDanger(x-20, 420, 80,"TYPE03B", x, 480, 0.8, 240,  [03, x-20, 420, 4, 120] );	
		loop(20){yield}
	}


	ascent(i in 0..6){
		let x = GetCenterX()+140 - 180*(i/5)+20;
		stage_CreateEnemyWithDanger(x-20, 80, 80,"TYPE03B", x, 0, 0.8, 120, [03, x-20, 80, 4, 240] );	
		loop(20){yield}
	}

	loop(40){yield;}
	loop(10){
		local{
			let x = rand(50,120);
			let y = rand(390,450);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), 450, 460, 0, 0, [01, x, y, 1.6, rand(270,360)] );	
		}
		loop(15){yield}
	}

	loop(100){yield;}
	stage_StopGameover();

//sequence 3--------------------------------------

	m_practice_text = "Sequence 3/5";

	stage_Danger(GetCenterX(), GetCenterY()-120);
	stage_Danger(GetCenterX()-120, GetCenterY());
	stage_Danger(GetCenterX(), GetCenterY()+120);
	stage_Danger(GetCenterX()+120, GetCenterY());
	stage_CreateEnemyWithDanger(GetCenterX(), GetCenterY()-60, 80,"TYPE04B", GetCenterX(), 0, 0, 0, [03, GetCenterX(), GetCenterY()-60, 3, 270]);	
	stage_CreateEnemyWithDanger(GetCenterX()-60, GetCenterY(), 80,"TYPE04B", 0, GetCenterY(), 0, 0, [03, GetCenterX()-60, GetCenterY(), 3, 180]);	
	stage_CreateEnemyWithDanger(GetCenterX(), GetCenterY(), 80,"TYPE04B", GetCenterX(), 0, 0, 0, [03, GetCenterX(), GetCenterY(), 3, 90]);	
	stage_CreateEnemyWithDanger(GetCenterX()+60, GetCenterY(), 80,"TYPE04B", 420, GetCenterY(), 0, 0, [03, GetCenterX()+60, GetCenterY(), 3, 0]);	
	stage_CreateEnemyWithDanger(GetCenterX(), GetCenterY()+60, 80,"TYPE04B", GetCenterX(), 470, 0, 0, [03, GetCenterX(), GetCenterY()+60, 3, 90]);	
	loop(140){yield;}

	stage_CreateEnemyWithDanger(GetCenterX(), 80, 80,"TYPE03C", GetCenterX(), 0, 0, 0, [03, GetCenterX(), 80, 1, 270]);	
	loop(160){yield;}

	stage_CreateEnemyWithDanger(GetCenterX()-100, 80, 80,"TYPE03C", GetCenterX()-100, 0, 0, 0, [03, GetCenterX()-100, 80, 1, 90]);	
	stage_CreateEnemyWithDanger(GetCenterX()+100, 80, 80,"TYPE03C", GetCenterX()+100, 0, 0, 0, [03, GetCenterX()+100, 80, 1, 90]);	
	loop(160){yield;}

	stage_CreateEnemyWithDanger(GetCenterX(), 420, 80,"TYPE03C", GetCenterX(), 470, 0, 0, [03, GetCenterX(), 420, 1, 270]);	

	loop(5){
		stage_CreateEnemyWithDanger(GetCenterX()-120, 80, 80,"TYPE01A", GetCenterX()-120, 0, 0, 0, [02, GetCenterX()-120, 80, 1.9, 80]);	
		loop(15){yield}
		stage_CreateEnemyWithDanger(GetCenterX()-80, 80, 80,"TYPE01A", GetCenterX()-80, 0, 0, 0, [02, GetCenterX()-80, 80, 1.3, 80] );	
		loop(15){yield}
		stage_CreateEnemyWithDanger(GetCenterX()+120, 80, 80, "TYPE01A", GetCenterX()+120, 0, 0, 0, [02, GetCenterX()+120, 80, 1.9, 80]);	
		loop(15){yield}
		stage_CreateEnemyWithDanger(GetCenterX()+80, 80, 80, "TYPE01A", GetCenterX()+80, 0, 0, 0, [02, GetCenterX()+80, 80, 1.3, 80] );	
		loop(15){yield}
	}

	loop(100){yield;}
	stage_StopGameover();


//sequence 4--------------------------------------

	m_practice_text = "Sequence 4/5";

	loop(120){yield;}

	stage_CreateEnemyWithDanger(100, GetCenterY()-100, 80,"TYPE04A", 0, GetCenterY()-100, 0, 0, [03, 100, GetCenterY()-100, 2, 180]);	
	stage_CreateEnemyWithDanger(90, GetCenterY(), 80,"TYPE04B", 0, GetCenterY(), 0, 0, [03, 90, GetCenterY(), 2, 180]);	
	stage_CreateEnemyWithDanger(100, GetCenterY()+100, 80,"TYPE04A", 0, GetCenterY()+100, 0, 0, [03, 100, GetCenterY()+100, 2, 180]);	

	loop(120){yield;}
	stage_CreateEnemyWithDanger(370, GetCenterY()-100, 80,"TYPE04A", 460, GetCenterY()-100, 0, 0, [03, 370, GetCenterY()-100, 2, 0]);	
	stage_CreateEnemyWithDanger(380, GetCenterY(), 80,"TYPE04B", 460, GetCenterY(), 0, 0, [03, 380, GetCenterY(), 2, 0]);	
	stage_CreateEnemyWithDanger(370, GetCenterY()+100, 80,"TYPE04A", 460, GetCenterY()+100, 0, 0, [03, 370, GetCenterY()+100, 2, 0]);	


	//return;
	loop(120){yield;}
	ascent(i in 0..5){
		stage_Danger(GetCenterX()-180+360*(i/4), 70);
	}
	loop(70){yield;}
	loop(3){
		let x = GetCenterX()+rand(-50,160);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), 0, GetClipMinY(), 1, 90, [02, x, 80, 4, 270] );	
		loop(50){yield}
		let x = GetCenterX()+rand(-160,50);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), GetClipMaxX()+20, GetClipMinY(), 1, 90,  [02, x, 80, 4, 270] );	
		loop(50){yield}
	}
	loop(30){yield;}

	ascent(i in 0..5){
		stage_Danger(GetCenterX()-180+360*(i/4), 70);
	}
	loop(70){yield;}
	loop(6){
		let x = GetCenterX()+rand(-50,160);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01B"), 0, GetClipMinY(), 1, 90, [02, x, 80, 4, 270] );	
		loop(20){yield}
		let x = GetCenterX()+rand(-160,50);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01B"), GetClipMaxX()+20, GetClipMinY(), 1, 90,  [02, x, 80, 4, 270] );	
		loop(20){yield}
	}
	loop(100){yield;}

	ascent(i in 0..5){
		stage_Danger(GetCenterX()-180+360*(i/4), 70);
	}
	loop(70){yield;}
	loop(15){
		let x = GetCenterX()+rand(-50,160);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01C"), 0, GetClipMinY(), 1, 90, [02, x, 80, 4, 270] );	
		loop(5){yield}
		let x = GetCenterX()+rand(-160,50);
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01C"), GetClipMaxX()+20, GetClipMinY(), 1, 90,  [02, x, 80, 4, 270] );	
		loop(5){yield}
	}
	stage_StopGameover();


//sequence 5--------------------------------------

	m_practice_text = "Sequence 5/5";

	loop(120){yield;}

//	stage_TaskCreateEnemy(5, 10, 70, "TYPE01B", GetCenterX()-120, 0, 0, 0, [01, GetCenterX()-120, 80, 0.7, 90]);
//	stage_TaskCreateEnemy(5, 45, 70, "TYPE01B", GetCenterX()+120, 0, 0, 0, [01, GetCenterX()+120, 80, 0.7, 90]);


	loop(5){
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01B"), GetCenterX()-120, 0, 0, 0, [01, GetCenterX()-120, 80, 0.7, 90]);	
		loop(35){yield}
		CreateEnemyFromFile(system_GetEnemyPath("TYPE01B"), GetCenterX()+120, 0, 0, 0, [01, GetCenterX()+120, 80, 0.7, 90] );	
		loop(35){yield}
	}


	loop(140){yield;}
	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)-20;
		loop(20){yield}
		stage_CreateEnemyWithDanger(x+20, 80, 80,"TYPE02B", x, 0, 0.8, 60, [03, x+20, 80, 4, 300] );
//		CreateEnemyFromFile(system_GetEnemyPath("TYPE02B"), x, 0, 0.8, 60, [03, x+20, 80, 4, 300] );	
	}
	loop(80){yield;}

	ascent(i in 0..6){
		let x = GetCenterX()+140 - 180*(i/5)+20;
		stage_CreateEnemyWithDanger(x-20, 80, 80,"TYPE02B", x, 0, 0.8, 120, [03, x-20, 80, 4, 240] );	
		loop(20){yield}
	}
	loop(30){yield;}

	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)-20;
		stage_CreateEnemyWithDanger(x+20, 420, 80,"TYPE02C", x, 480, 0.8, 300,  [03, x+20, 420, 4, 60] );	
		loop(20){yield}
	}
	loop(80){yield;}

	ascent(i in 0..6){
		let x = GetCenterX()-140 + 180*(i/5)+20;
		stage_CreateEnemyWithDanger(x-20, 420, 80,"TYPE02C", x, 480, 0.8, 240,  [03, x-20, 420, 4, 120] );	
		loop(20){yield}
	}
	loop(180){yield;}



	ascent(i in 0..9){
		let x = GetCenterX()-140 + 280*(i/8);
		let y = GetCenterY()-140 + 280*(i/8);
		stage_CreateEnemyWithDanger(x, 80, 80,"TYPE02B", x, 0, 0.6, 90,  [03, x, 80, 4, 270] );	
		stage_CreateEnemyWithDanger(55, y, 80,"TYPE02B", 0,y, 0.6, 0,  [03, 55, y, 4, 180] );	
		stage_CreateEnemyWithDanger(x, GetClipMaxY()-30, 80,"TYPE02B", x, GetClipMaxY() + 20, 0.6, 270,  [03, x, GetClipMaxY()-30, 4, 90] );	
		stage_CreateEnemyWithDanger(GetClipMaxX - 30, y, 80,"TYPE02B", GetClipMaxX + 20, y, 0.6, 180,  [03, GetClipMaxX - 30, y, 4, 0]);	
	}

	loop(140){yield;}


	ascent(j in 0..12){
		ascent(i in 0..6){
			stage_Danger(GetCenterX()-250 + 400*(i/5), 70 + 350*(j/11));
		}
	}

	loop(100){yield;}
	loop(10){
		ascent(i in 0..6){
			let x = GetCenterX()-200 + 400*(i/5);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), x, 0, 00, 00, [01, x, 80, 4, 90] );
		}
		loop(5){yield;}
	}

	loop(10){yield;}
	ascent(j in 0..6){
		ascent(i in 0..4){
			let x = GetCenterX()-200 + 400*(i/4);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), x-20, 0, 00, 00, [01, x, 80, 4, 60+(j*4)] );
		}
		ascent(i in 0..4){
			let x = GetCenterX()-200 + 400*(i/4);
			CreateEnemyFromFile(system_GetEnemyPath("TYPE01A"), x+20, 0, 00, 00, [01, x+40, 80, 4, 120-(j*4)] );
		}
		loop(5){yield;}
	}

	loop(25){yield;}
	loop(200){yield;}
	ascent(i in 0..5){
		let x = GetCenterX()-150 + 300*(i/4)-40;
		stage_CreateEnemyWithDanger(x+20, 80, 80,"TYPE03A", x, 0, 00, 00, [03, x+20, 80, 1.5, 90] );
		x = GetCenterX()-150 + 300*(i/4)+40;
		stage_CreateEnemyWithDanger(x-20, 420, 80,"TYPE03A", x, 480, 00, 00, [03, x-20, 420, 1.5, 270] );
	}
	ascent(j in 0..3){
		ascent(i in 0..5){
			let x = GetCenterX()-150 + 300*(i/4)-20;
			CreateEnemyFromFile(system_GetEnemyPath("TYPE03B"), x, 0, 00, 00, [03, x+20, 80, 1, 130 - 80 *(j/3)] );
		}
		ascent(i in 0..5){
			let x = GetCenterX()-150 + 300*(i/4)+20;
			CreateEnemyFromFile(system_GetEnemyPath("TYPE03A"), x, 480, 00, 00, [03, x-20, 420, 1, 230 + 80 *(j/3)] );
		}
		loop(20){yield;}
	}
	stage_StopGameover();


//sequence final--------------------------------------

	m_practice_text = "Sequence Final";

	loop(300){yield;}
	stage_StopGameover();


if(GetScore() < 5000000){

	once_BackGroundGraphicCloud(6,100,false);
	loop(100){yield;}
	once_BackGroundGraphicCloud(6,200,false);
	loop(200){yield;}

	CreateEnemyFromFile(system_GetEnemyPath("TYPE_BOSS00"), GetClipMinX(), GetCenterY()-120, 0,0,0);

	ascent(i in 0..60){
		local{
			let ang = 720 * (i/60)-90;
			let x =GetCenterX() +  (GetCenterX()-GetClipMinX() - 20) * cos(ang);
			let y =GetCenterY() +  (GetCenterY()-GetClipMinY() - 20) * sin(ang);
			stage_CreateEnemyWithDanger(x, y, 80,"TYPEXXA",  x + (30) * cos(ang), y + (30) * sin(ang), 0.0, 000,  [02, x, y, 4, 60] );	
		}
		local{
			let ang = -720 * (i/60)-90;
			let x =GetCenterX() +  (GetCenterX()-GetClipMinX() - 20) * cos(ang);
			let y =GetCenterY() +  (GetCenterY()-GetClipMinY() - 20) * sin(ang);
			stage_CreateEnemyWithDanger(x, y, 80,"TYPE01A",  x + (30) * cos(ang), y + (30) * sin(ang), 0.0, 000,  [02, x, y, 4, 60] );	
		}

		loop(40 + (-35)*(i/60)){yield}
	}
	loop(400){yield;}
	stage_StopGameover();
	stage_ComboStop();
	stage_TaskGameClear(false);
	loop(250){yield;}
	FadeOutMusic(bgm_01, 10);

	loop(200){yield;}

	SetClearFrameEffectEnable(true);
	ClearStage();

}else{

	once_BackGroundGraphicCloud(6,100,true);
	loop(100){yield;}
	once_BackGroundGraphicCloud(6,160,true);
	loop(200){yield;}

	stage_ComboStop();
	loop(300){yield;}
	FadeOutMusic(bgm_01, 20);

	stage_Danger(GetCenterX()-30, GetCenterY()-60);
	stage_Danger(GetCenterX()+30, GetCenterY()-60);
	stage_Danger(GetCenterX()-30, GetCenterY()-90);
	stage_Danger(GetCenterX()+30, GetCenterY()-90);
	stage_Danger(GetCenterX()-30, GetCenterY()-120);
	stage_Danger(GetCenterX()+30, GetCenterY()-120);
	loop(100){yield;}

	CreateEnemyBossFromFile(system_GetEnemyPath("TYPE_BOSS01"), GetCenterX(), 00, 0, 0, 0);	

	stage_ComboStart();

	PlayMusic(bgm_02);
	loop(240){yield;}

	while(!GetCommonDataEx("SPHERIA_ENEMY", "ENEMY_BOSS_FINAL")){loop(30){ yield;} }
	FadeOutMusic(bgm_02, 40);
	loop(100){yield;}
	PlayMusic(bgm_03);

	stage_WaitForEnemyDefeat();
	stage_StopGameover();
	stage_ComboStop();
	FadeOutMusic(bgm_03, 30);
	stage_TaskGameClear(true);
	loop(450){yield;}
	stage_Ending();

}


//Retry();

}//end function



task stage_TaskCreateEnemy(let loop_num, let wait_start, let wait, let type, let x, let y, let speed, let angle, let arg){

	loop(wait_start){yield;}
	loop(loop_num){
		CreateEnemyFromFile(system_GetEnemyPath(type), x, y, speed, angle,  arg);	
		loop(wait){yield;}
	}

}//end task

