task MusicControl{
let stage;								//ステージ数を格納する変数
let Music1 = GetCurrentScriptDirectory~"\Bgm\ametowa.mp3";		//ステージ１音楽
let Music2 = GetCurrentScriptDirectory~"\Bgm\fukaki.mp3";		//ステージ２音楽
let Music3 = GetCurrentScriptDirectory~"\Bgm\toki.mid";			//ステージ３音楽
let Music4 = GetCurrentScriptDirectory~"\Bgm\ginjukai.mp3";		//ステージ４音楽
let Music5 = GetCurrentScriptDirectory~"\Bgm\minosuisyou.mid";		//ステージ５音楽
let Music6A = GetCurrentScriptDirectory~"\Bgm\edge.mp3";		//ステージ６Ａ音楽
let Music6B = GetCurrentScriptDirectory~"\Bgm\emergency.mp3";		//ステージ６Ｂ音楽
let MusicFinal = GetCurrentScriptDirectory~"\Bgm\set_us_free_loop.mp3";	//ステージファイナル音楽

LoadMusic(Music1);
stage = GetCommonData("STAGE");						//共通データでステージ数を確認

if(stage == 1){PlayMusic(Music1);}					//１面なら、１面音楽を鳴らす
while(stage == 1){stage = GetCommonData("STAGE");yield;}		//１面が終わるまで待機
DeleteMusic(Music1);							//１面音楽をメモリから削除
LoadMusic(Music2);
if(stage == 2){PlayMusic(Music2);}					//２面なら、２面音楽を鳴らす
while(stage == 2){stage = GetCommonData("STAGE");yield;}		//２面が終わるまで待機
DeleteMusic(Music2);							//２面音楽をメモリから削除
LoadMusic(Music3);
if(stage == 3){PlayMusic(Music3);}					//３面なら、３面音楽を鳴らす
while(stage == 3){stage = GetCommonData("STAGE");yield;}		//３面が終わるまで待機
DeleteMusic(Music3);							//３面音楽をメモリから削除
LoadMusic(Music4);
if(stage == 4){PlayMusic(Music4);}					//４面なら、４面音楽を鳴らす
while(stage == 4){stage = GetCommonData("STAGE");yield;}		//４面が終わるまで待機
DeleteMusic(Music4);							//４面音楽をメモリから削除
LoadMusic(Music5);
if(stage == 5){PlayMusic(Music5);}					//５面なら、５面音楽を鳴らす
while(stage == 5){stage = GetCommonData("STAGE");yield;}		//５面が終わるまで待機
DeleteMusic(Music5);							//５面音楽をメモリから削除

LoadMusic(Music6A);
LoadMusic(Music6B);						
if(stage == 6){
if(GetCommonData("STAGE6_CHOOSE") == 1){PlayMusic(Music6A);}		//６Ａ面なら、６Ａ面音楽を鳴らす
if(GetCommonData("STAGE6_CHOOSE") == 2){PlayMusic(Music6B);}		//６Ｂ面なら、６Ｂ面音楽を鳴らす
}
while(stage == 6){stage = GetCommonData("STAGE");yield;}		//６面が終わるまで待機
DeleteMusic(Music6A);							//６Ａ面音楽をメモリから削除
DeleteMusic(Music6B);							//６Ｂ面音楽をメモリから削除
LoadMusic(MusicFinal);
if(stage == 7){PlayMusic(MusicFinal);}					//最終面なら、最終面音楽を鳴らす
while(stage == 7){stage = GetCommonData("STAGE");yield;}		//最終面が終わるまで待機
DeleteMusic(MusicFinal);						//最終面音楽をメモリから削除
loop{yield;}
}

task BGControl{
SetCommonData("ON_SPELL",0);
let stage;
let spell;
let BG1 = GetCurrentScriptDirectory~"\BG\yun_3780.jpg";
let BG2 = GetCurrentScriptDirectory~"\BG\eyes0048.jpg";
let BG3 = GetCurrentScriptDirectory~"\BG\seiryu808.jpg";
let BG4 = GetCurrentScriptDirectory~"\BG\yun_6914.jpg";
let BG5 = GetCurrentScriptDirectory~"\BG\yun_5626.jpg";
let BG6 = GetCurrentScriptDirectory~"\BG\ki809.jpg";
let BG7 = GetCurrentScriptDirectory~"\BG\1350-italy09-009.jpg";

stage = GetCommonData("STAGE");

LoadGraphic(BG1);
if(stage == 1){
SetTexture(BG1);SetGraphicRect(0,0,384,448);SetAlpha(150);yield;}
while(stage == 1){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG1);


stage = GetCommonData("STAGE");

LoadGraphic(BG2);SetGraphicScale(2,2);
if(stage == 2){
SetTexture(BG2);SetGraphicRect(0,0,384,448);SetAlpha(150);yield;}
while(stage == 2){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG2);


stage = GetCommonData("STAGE");

LoadGraphic(BG3);SetGraphicScale(1,1);
if(stage == 3){
SetTexture(BG3);SetGraphicRect(0,0,384,448);SetAlpha(200);yield;}
while(stage == 3){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG3);

stage = GetCommonData("STAGE");

LoadGraphic(BG4);
if(stage == 4){
SetTexture(BG4);SetGraphicRect(0,0,384,448);SetAlpha(170);yield;}
while(stage == 4){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG4);

stage = GetCommonData("STAGE");

LoadGraphic(BG5);
if(stage == 5){
SetTexture(BG5);SetGraphicRect(0,0,384,448);SetAlpha(200);yield;}
while(stage == 5){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG5);

stage = GetCommonData("STAGE");

LoadGraphic(BG6);
if(stage == 6){
SetTexture(BG6);SetGraphicRect(0,0,384,448);SetAlpha(200);yield;}
while(stage == 6){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG6);

stage = GetCommonData("STAGE");

LoadGraphic(BG7);
if(stage == 7){
SetTexture(BG7);SetGraphicRect(0,0,384,448);SetAlpha(180);yield;}
while(stage == 7){stage = GetCommonData("STAGE");yield;}
DeleteGraphic(BG7);

}