//////////////////ハイスコア名前空間///////////////////////////////////////////////
/*
let NsHiScoreReimuAEasy=[];
let NsHiScoreReimuANormal=[];
let NsHiScoreReimuAHard = [];

let NsHiScoreReimuBEasy = [];
let NsHiScoreReimuBNormal = [];
let NsHiScoreReimuBHard = [];

let NsHiScoreReimuAEasy2=[];
let NsHiScoreReimuANormal2=[];
let NsHiScoreReimuAHard2 = [];

let NsHiScoreReimuBEasy2 = [];
let NsHiScoreReimuBNormal2 = [];
let NsHiScoreReimuBHard2 = [];
*/

let NsHiScoreReimuAEasy=[0.1,1.1,2.1,3.1,4.1,5.1,6.1,7.1,8.1,9.1];
let NsHiScoreReimuANormal=[10.1,11.1,12.1,13.1,14.1,15.1,16.1,17.1,18.1,19.1];
let NsHiScoreReimuAHard = [20.1,21.1,22.1,23.1,24.1,25.1,26.1,27.1,28.1,29.1];

let NsHiScoreReimuBEasy = [0.2,1.2,2.2,3.2,4.2,5.2,6.2,7.2,8.2,9.2];
let NsHiScoreReimuBNormal = [10.2,11.12,2.2,13.2,14.2,15.2,16.2,17.2,18.2,19.2];
let NsHiScoreReimuBHard = [20.2,21.2,22.2,23.2,24.2,25.2,26.2,27.2,28.2,29.2];

let NsHiScoreReimuAEasy2=[0.11,1.11,2.11,3.11,4.11,5.11,6.11,7.11,8.11,9.11];
let NsHiScoreReimuANormal2=[10.11,11.11,12.11,13.11,14.11,15.11,16.11,17.11,18.11,19.11];
let NsHiScoreReimuAHard2 = [20.11,21.11,22.11,23.11,24.11,25.11,26.11,27.11,28.11,29.11];

let NsHiScoreReimuBEasy2 = [0.22,1.22,2.22,3.22,4.22,5.22,6.22,7.22,8.22,9.22];
let NsHiScoreReimuBNormal2 = [10.22,11.22,12.22,13.22,14.22,15.22,16.22,17.22,18.22,19.22];
let NsHiScoreReimuBHard2 = [20.22,21.22,22.22,23.22,24.22,25.22,26.22,27.22,28.22,29.22];

/*
ascent(let k in 0..10)
{
NsHiScoreReimuAEasy=NsHiScoreReimuAEasy ~ [k];
NsHiScoreReimuANormal=NsHiScoreReimuANormal ~ [k];
NsHiScoreReimuAHard =NsHiScoreReimuAHard ~ [k];

NsHiScoreReimuBEasy =NsHiScoreReimuBEasy ~ [k];
NsHiScoreReimuBNormal =NsHiScoreReimuBNormal ~ [k];
NsHiScoreReimuBHard =NsHiScoreReimuBHard  ~ [k];

NsHiScoreReimuAEasy2=NsHiScoreReimuAEasy2 ~ [k];
NsHiScoreReimuANormal2=NsHiScoreReimuANormal2 ~ [k];
NsHiScoreReimuAHard2 =NsHiScoreReimuAHard2 ~ [k];

NsHiScoreReimuBEasy2 =NsHiScoreReimuBEasy2 ~ [k];
NsHiScoreReimuBNormal2 =NsHiScoreReimuBNormal2 ~ [k];
NsHiScoreReimuBHard2 =NsHiScoreReimuBHard2  ~ [k];

}


ascent(let k in 0..10)
{
NsHiScoreReimuAEasy[k]=		k+0.1;
NsHiScoreReimuANormal[k]=	k+10.1;	
NsHiScoreReimuAHard[k]=		k+20.1;

NsHiScoreReimuBEasy[k]=		k+0.2;
NsHiScoreReimuBNormal[k]=	k+10.2;
NsHiScoreReimuBHard[k]=		k+20.2;

NsHiScoreReimuAEasy2[k]=	k+0.11;
NsHiScoreReimuANormal2[k]=	k+10.11;	
NsHiScoreReimuAHard2[k]=	k+20.11;

NsHiScoreReimuBEasy2[k]=	k+0.22;
NsHiScoreReimuBNormal2[k]=	k+10.22;
NsHiScoreReimuBHard2[k]=	k+20.22;

}
*/
let NsUpTime = "UP_TIME";
let NsPlayTime = "PLAY_TIME";
///////////プレイ回数部///////////////////////////////////////////////////////////
let NsFrequencyReimuAEasy = "F_RA_E";
let NsFrequencyReimuANormal = "F_RA_N";
let NsFrequencyReimuAHard = "F_RA_H";

let NsFrequencyReimuBEasy = "F_RB_E";
let NsFrequencyReimuBNormal = "F_RB_N";
let NsFrequencyReimuBHard = "F_RB_H";

//////////////////////////////////////////////////////////////////////////////////////////

// w フレームだけ待つ
function wait(w) 
{
    loop(w) { yield; }
}

function WaitForZeroEnemy()//敵数が0になるまで待機する関数
{
	while(GetEnemyNum() != 0){yield;}
}

function ItemSet(x,y,type)//アイテム生成関数
{
	let XY=GetCommonDataDefault("ItemXY",[]);//共通データ内容を変数に渡す
	XY=XY~[x,y,type];//
	SetCommonData("ItemXY",XY);//共通データに変更後の配列を渡す
}

///////////////////////////////////////////////////////////////////////////////////////////
	let csd = GetCurrentScriptDirectory;
	let imgLetter =csd ~ "img/border.png"; 
	let DefinedPlayer1="MarisaA.txt";
	let DefinedPlayer2="MarisaB.txt";
//	let DefinedPlayer3="ReimuA.txt";
//	let DefinedPlayer4="ReimuB.txt";
//	let DefinedPlayer5="USER_PLAYER";
	//let DefinedPlayer6=
	let DrawDefinedPlayer1="霧雨魔理沙　A";
	let DrawDefinedPlayer2="霧雨魔理沙　B";
	let DrawDefinedPlayer3="霧雨魔理沙　A";
	let DrawDefinedPlayer4="霧雨魔理沙　B";

	let SelectedCharacter=GetPlayerScriptName;
	if(SelectedCharacter=="MarisaAAuto.txt")
	{
		SelectedCharacter="MarisaA.txt"
	}
	if(SelectedCharacter=="MarisaBAuto.txt")
	{
		SelectedCharacter="MarisaB.txt"
	}

////////////////////////////////////////////////////////////////////////////////////////////

//スコアのセーブファイル

let savePathstage = GetCurrentScriptDirectory~"SaveData.dat";//ステージで読み込む
let savePath = GetCurrentScriptDirectory~"..\SaveData.dat";//スペルで読み込む

/////////////////////////////////////////////////////////////////////////////////////////////
//名前空間
let NsScore = "SAVE_SCORE";	//スコア
let NsHi = "HI_SCORE";	//ハイスコア(NsScore)

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

let NsGetSpell = "GET_SPELL";	//スペカ取得枚数(Common)
let NsIsReplay = "IS_REPLAY";	//リプレイかどうか(Common)
let NsIsReplayJudgment = "IS_REPLAY_JUDGMENT";//リプレイかどうかリトライ関係(Common)	

let NsDefeatFrame = "DEFEAT_FRAME";	//撃破フレーム(Common)
let NsDefeatPosX = "DEFEAT_POSX";	//撃破位置(Common)
let NsDefeatPosY = "DEFEAT_POSY";	//撃破位置(Common)
let NsBossFrame = "BOSS_FRAME";	//ボス攻撃開始からのフレーム(Common)

///////////////////////////////////////////////////////////////////////////////////////////////

//ボス再生に使用するコモンエリアのロード
function LoadBossAreas()
{
	CreateCommonDataArea(NsScore);
	LoadCommonDataEx(NsScore,savePath);
	SetCommonData(NsGetSpell,0);
	let isRep = IsReplay();
	SetCommonData(NsIsReplay,isRep);
}



//ボス再生に使用するコモンエリアのセーブ、削除
function DeleteBossAreas()
{
	if(GetCommonDataDefault(NsIsReplay,true) == false)
	{
		SaveCommonDataEx(NsScore,savePath);
	}
	ClearCommonDataEx(NsScore);
	DeleteCommonData(NsGetSpell);
	DeleteCommonData(NsDefeatFrame);
	DeleteCommonData(NsDefeatPosX);
	DeleteCommonData(NsDefeatPosY);
	DeleteCommonData(NsBossFrame);
	DeleteCommonData(NsIsReplay);
}


	function NumToString(let num)
	{
		if(num==0)
		{
			num=0.1;
		}
		let leng = trunc(log10(num))+1;//整数部分の桁数を求める
		let string = ToString(num);//数字を文字列に変える
		let str = " ";
			times(12-leng)
			{
				string = str ~ string;//桁揃え用のスペースを先頭につける。
			} 
		return string[0..12];//文字列をスライシングして返す
	}

////////////////////////////////////////////////////////////////////////////////////////////
task DisPlayNumber(let x,let y,let number,let number2)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*12,y,num[i]);
		}
	}
	if(num[0]==0)
	{
		DisplayNumLetter(x,y,0);
	}
}

task DisPlayScoreNumber(let x,let y,let number,let number2)
{
if(number2!=0)
{
	number+=1000000;
}
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..7)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*12,y,num[i]);
		}
	}
	if(num[0]==0)
	{
		DisplayNumLetter(x,y,0);
	}
}

task DisPlayScoreNumber2(let x,let y,let number,let number2)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*12,y,num[i]);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
}

task DisplayNumLetter(let x,let y,let num)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

	/*	ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
	*/	
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task DisPlayGetItemScore(let x,let y,let number,let color)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayGetItemScoreLetter(x-(i-1)*6,y,num[i],color);
		}
	}
	if(num[0]==0)
	{
		DisplayGetItemScoreLetter(x,y,0,color);
	}
}

task DisplayGetItemScoreLetter(let x,let y,let num,let color)
{
		let scx=0.6;
		let scy=0.6;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgLetter);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -7, -8);
		ObjEffect_SetVertexXY(obj, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj, 2, 7, 8);
		ObjEffect_SetVertexXY(obj, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj, 0,  2+14*num,  114);
		ObjEffect_SetVertexUV(obj, 1,  14+14*num, 114);
		ObjEffect_SetVertexUV(obj, 2, 14+14*num,  131);
		ObjEffect_SetVertexUV(obj, 3, 2+14*num, 131);

if(color=="white")
{
		ObjEffect_SetVertexColor(obj,0,100,255,255,255);
		ObjEffect_SetVertexColor(obj,1,100,255,255,255);
		ObjEffect_SetVertexColor(obj,2,100,255,255,255);
		ObjEffect_SetVertexColor(obj,3,100,255,255,255);
}

if(color=="yellow")
{
		ObjEffect_SetVertexColor(obj,0,100,255,255,150);
		ObjEffect_SetVertexColor(obj,1,100,255,255,150);
		ObjEffect_SetVertexColor(obj,2,100,255,255,150);
		ObjEffect_SetVertexColor(obj,3,100,255,255,150);
}
		
		ObjEffect_SetScale(obj, scx,scy);
		Obj_SetPosition(obj,x,y);
		ObjEffect_SetLayer(obj,2);
		wait(30);
		Obj_Delete(obj);
}

task ResultNumberDisPlay(let x,let y,let number,Alpha,R,G,B)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			ResultNumLetterDisplay(x-(i-1)*12,y+5.5,num[i],Alpha,R,G,B);
		}
	}
	if(num[0]==0)
	{
		ResultNumLetterDisplay(x,y+5,0,Alpha,R,G,B);
	}
}

task ResultNumLetterDisplay(let x,let y,let num,Alpha,R,G,B)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task CrearBonus
{
let dx=0;
let DBonus;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","Normal"))
	case("Easy")
	{
		DBonus=0.5;
	}
	case("Normal")
	{
		DBonus=1;
	}
	case("Hard")
	{
		DBonus=1.5;
	}
	case("Lunatic")
	{
		DBonus=2;
	}
	case("Extra")
	{
		DBonus=2.5;
	}
	let bonusscore=(GetPlayerLife-1)*100000+GetPlayerBomb*25000+trunc(GetCommonData("BONUSPOINT"))+trunc(GetCommonData("POWERMAX"))*10;
	bonusscore=bonusscore*DBonus;
	if(bonusscore>=1000000)
	{
		dx=12;
	}
	CrearBonusDisplay(GetCenterX+36+dx,GetCenterY-20,bonusscore);
	wait(180);
	loop(100)
	{
		AddScore(bonusscore);
		yield;
	}
}

task CrearBonusDisplay(x,y,number)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayCrearBonusNumLetter(x-(i-1)*24,y,num[i]);
		}
	}
	DisplayCrearBonusNumLetter(x+24,y,0);
	DisplayCrearBonusNumLetter(x+48,y,0);
	if(num[0]==0)
	{
		DisplayCrearBonusNumLetter(x,y,0);
	}
}

task DisplayCrearBonusNumLetter(let x,let y,let num)
{
		let scx=2;
		let scy=2;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgLetter);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -7, -8);
		ObjEffect_SetVertexXY(obj0, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj0, 2, 7, 8);
		ObjEffect_SetVertexXY(obj0, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj0, 0,  2+14*num,  114);
		ObjEffect_SetVertexUV(obj0, 1,  14+14*num, 114);
		ObjEffect_SetVertexUV(obj0, 2, 14+14*num,  131);
		ObjEffect_SetVertexUV(obj0, 3, 2+14*num, 131);

		ObjEffect_SetVertexColor(obj0,0,200,255,255,255);
		ObjEffect_SetVertexColor(obj0,1,200,255,255,255);
		ObjEffect_SetVertexColor(obj0,2,200,150,150,255);
		ObjEffect_SetVertexColor(obj0,3,200,150,150,255);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y);
		ObjEffect_SetLayer(obj0,8);
		wait(240);
		Obj_Delete(obj0);
}

task ResultHiscoreDisPlay(let x,let y,let number,let number2)
{
if(number2>=0)
{
	number+=1000000;
}
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..7)
	{
		if(num[0]>=10^(i-1))
		{
			ResultHiscoreNumDisplay(x-(i-1)*10,y,num[i],255,200,200,255);
		}
	}
	if(num[0]==0)
	{
		ResultHiscoreNumDisplay(x,y,0,255,200,200,255);
	}
}

task ResultHiscoreDisPlay2(let x,let y,let number,let number2)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);

if(x!=130)
{
	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			ResultHiscoreNumDisplay(x-(i-1)*10,y,num[i],255,255,200,200);
		}
	}
	if(num[0]==0)
	{
		//ResultHiscoreNumDisplay(x,y,0,255,200,200,255);
	}
}
else
{
	ascent(let i in 1..10)
	{
		if(num[0]>=10^(i-1))
		{
			ResultHiscoreNumDisplay(x-(i-1)*12,y,num[i],255,200,200,255);
		}
	}
}
}

task ResultHiscoreNumDisplay(let x,let y,let num,Alpha,R,G,B)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task TimeBonusNumDisplay(let x,let y,let number,Alpha,R,G,B)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..4)
	{
		if(num[0]>=10^(i-1))
		{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B);
		}
	}
			TimeBonusDisplayNumLetter(x-(4-1)*12,y,10,Alpha,R,G,B);
	ascent(let i in 4..6)
	{
		if(num[0]>=10^(i-1))
		{
			TimeBonusDisplayNumLetter(x-(i)*12,y,num[i],Alpha,R,G,B);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
}

task BossRateNumDisplay(let x,let y,let number,Alpha,R,G,B)
{
let num=[];
ascent(let k in 0..11)
{
num = num ~ [k];
}
	num[0]=trunc(number);
	num[1]=trunc(number%10);
	num[2]=trunc(number%100/10);
	num[3]=trunc(number%1000/100);
	num[4]=trunc(number%10000/1000);
	num[5]=trunc(number%100000/10000);
	num[6]=trunc(number%1000000/100000);
	num[7]=trunc(number%10000000/1000000);
	num[8]=trunc(number%100000000/10000000);
	num[9]=trunc(number%1000000000/100000000);
	num[10]=trunc(number%10000000000/1000000000);


	ascent(let i in 1..4)
	{
		if(num[0]>=10^(i-1))
		{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B);
		}
	}
		//	TimeBonusDisplayNumLetter(x-(4-1)*12,y,10,Alpha,R,G,B);
	ascent(let i in 4..10)
	{
		if(num[0]>=10^(i-1))
		{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
}

task TimeBonusDisplayNumLetter(let x,let y,let num,Alpha,R,G,B)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
	
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task KakeruDisplay(let x,let y,Alpha,R,G,B)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgBer);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -11, -11);
		ObjEffect_SetVertexXY(obj0, 1, 11,  -11);
		ObjEffect_SetVertexXY(obj0, 2, 11, 11);
		ObjEffect_SetVertexXY(obj0, 3,  -11,  11);
		
		ObjEffect_SetVertexUV(obj0, 0,  7,  53);
		ObjEffect_SetVertexUV(obj0, 1,  29, 53);
		ObjEffect_SetVertexUV(obj0, 2, 29,  75);
		ObjEffect_SetVertexUV(obj0, 3, 7, 75);

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task PercentDisplay(let x,let y,Alpha,R,G,B)
{
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgBer);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -9, -18);
		ObjEffect_SetVertexXY(obj0, 1, 9,  -18);
		ObjEffect_SetVertexXY(obj0, 2, 9, 18);
		ObjEffect_SetVertexXY(obj0, 3,  -9,  18);
		
		ObjEffect_SetVertexUV(obj0, 0,  79,  46);
		ObjEffect_SetVertexUV(obj0, 1,  97, 46);
		ObjEffect_SetVertexUV(obj0, 2, 97,  81);
		ObjEffect_SetVertexUV(obj0, 3, 79, 81);

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}