//////////////////ハイスコア名前空間///////////////////////////////////////////////


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 NsHiScoreReimuALuna = ["30.1","31.1","32.1","33.1","34.1","35.1","36.1","37.1","38.1","39.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","12.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 NsHiScoreReimuBLuna = ["30.2","31.2","32.2","33.2","34.2","35.2","36.2","37.2","38.2","39.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 NsHiScoreReimuALuna2 = ["30.11","31.11","32.11","33.11","34.11","35.11","36.11","37.11","38.11","39.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"];
let NsHiScoreReimuBLuna2 = ["30.22","31.22","32.22","33.22","34.22","35.22","36.22","37.22","38.22","39.22"];

let NsHiScoreReimuCEasy=["0.3","1.3","2.3","3.3","4.3","5.3","6.3","7.3","8.3","9.3"];
let NsHiScoreReimuCNormal=["10.3","11.3","12.3","13.3","14.3","15.3","16.3","17.3","18.3","19.3"];
let NsHiScoreReimuCHard = ["20.3","21.3","22.3","23.3","24.3","25.3","26.3","27.3","28.3","29.3"];
let NsHiScoreReimuCLuna = ["30.3","31.3","32.3","33.3","34.3","35.3","36.3","37.3","38.3","39.3"];

let NsHiScoreReimuCEasy2=["0.33","1.33","2.33","3.33","4.33","5.33","6.33","7.33","8.33","9.33"];
let NsHiScoreReimuCNormal2=["10.33","11.33","12.33","13.33","14.33","15.33","16.33","17.33","18.33","19.33"];
let NsHiScoreReimuCHard2 = ["20.33","21.33","22.33","23.33","24.33","25.33","26.33","27.33","28.33","29.33"];
let NsHiScoreReimuCLuna2 = ["30.33","31.33","32.33","33.33","34.33","35.33","36.33","37.33","38.33","39.33"];

let NsHiScoreReimuDEasy=["0.4","1.4","2.4","3.4","4.4","5.4","6.4","7.4","8.4","9.4"];
let NsHiScoreReimuDNormal=["10.4","11.4","12.4","13.4","14.4","15.4","16.4","17.4","18.4","19.4"];
let NsHiScoreReimuDHard = ["20.4","21.4","22.4","23.4","24.4","25.4","26.4","27.4","28.4","29.4"];
let NsHiScoreReimuDLuna = ["30.4","31.4","32.4","33.4","34.4","35.4","36.4","37.4","38.4","39.4"];

let NsHiScoreReimuDEasy2=["0.44","1.44","2.44","3.44","4.44","5.44","6.44","7.44","8.44","9.44"];
let NsHiScoreReimuDNormal2=["10.44","11.44","12.44","13.44","14.44","15.44","16.44","17.44","18.44","19.44"];
let NsHiScoreReimuDHard2 = ["20.44","21.44","22.44","23.44","24.44","25.44","26.44","27.44","28.44","29.44"];
let NsHiScoreReimuDLuna2 = ["30.44","31.44","32.44","33.44","34.44","35.44","36.44","37.44","38.44","39.44"];

let NsHiScoreReimuEEasy=["0.5","1.5","2.5","3.5","4.5","5.5","6.5","7.5","8.5","9.5"];
let NsHiScoreReimuENormal=["10.5","11.5","12.5","13.5","14.5","15.5","16.5","17.5","18.5","19.5"];
let NsHiScoreReimuEHard = ["20.5","21.5","22.5","23.5","24.5","25.5","26.5","27.5","28.5","29.5"];
let NsHiScoreReimuELuna = ["30.5","31.5","32.5","33.5","34.5","35.5","36.5","37.5","38.5","39.5"];

let NsHiScoreReimuEEasy2=["0.55","1.55","2.55","3.55","4.55","5.55","6.55","7.55","8.55","9.55"];
let NsHiScoreReimuENormal2=["10.55","11.55","12.55","13.55","14.55","15.55","16.55","17.55","18.55","19.55"];
let NsHiScoreReimuEHard2 = ["20.55","21.55","22.55","23.55","24.55","25.55","26.55","27.55","28.55","29.55"];
let NsHiScoreReimuELuna2 = ["30.55","31.55","32.55","33.55","34.55","35.55","36.55","37.55","38.55","39.55"];


let NsHiScoreReimuALuna3 = ["30.111","31.111","32.111","33.111","34.111","35.111","36.111","37.111","38.111","39.111"];
let NsHiScoreReimuBLuna3 = ["30.222","31.222","32.222","33.222","34.222","35.222","36.222","37.222","38.222","39.222"];
let NsHiScoreReimuCLuna3 = ["30.333","31.333","32.333","33.333","34.333","35.333","36.333","37.333","38.333","39.333"];
let NsHiScoreReimuDLuna3 = ["30.444","31.444","32.444","33.444","34.444","35.444","36.444","37.444","38.444","39.444"];
let NsHiScoreReimuELuna3 = ["30.555","31.555","32.555","33.555","34.555","35.555","36.555","37.555","38.555","39.555"];

let NsHiScoreReimuALuna4 = ["30.1111","31.1111","32.1111","33.1111","34.1111","35.1111","36.1111","37.1111","38.1111","39.1111"];
let NsHiScoreReimuBLuna4 = ["30.2222","31.2222","32.2222","33.2222","34.2222","35.2222","36.2222","37.2222","38.2222","39.2222"];
let NsHiScoreReimuCLuna4 = ["30.3333","31.3333","32.3333","33.3333","34.3333","35.3333","36.3333","37.3333","38.3333","39.3333"];
let NsHiScoreReimuDLuna4 = ["30.4444","31.4444","32.4444","33.4444","34.4444","35.4444","36.4444","37.4444","38.4444","39.4444"];
let NsHiScoreReimuELuna4 = ["30.5555","31.5555","32.5555","33.5555","34.5555","35.5555","36.5555","37.5555","38.5555","39.5555"];

let NsStageHiScoreReimuAEasy=["100","100.1","100.2","100.3","100.4","100.5"];
let NsStageHiScoreReimuBEasy=["200","200.1","200.2","200.3","200.4","200.5"];
let NsStageHiScoreReimuCEasy=["300","300.1","300.2","300.3","300.4","300.5"];
let NsStageHiScoreReimuDEasy=["400","400.1","400.2","400.3","400.4","400.5"];
let NsStageHiScoreReimuEEasy=["500","500.1","500.2","500.3","500.4","500.5"];

let NsStageHiScoreReimuAEasy2=["105","100.11","100.22","100.33","100.44","100.55"];
let NsStageHiScoreReimuBEasy2=["205","200.11","200.22","200.33","200.44","200.55"];
let NsStageHiScoreReimuCEasy2=["305","300.11","300.22","300.33","300.44","300.55"];
let NsStageHiScoreReimuDEasy2=["405","400.11","400.22","400.33","400.44","400.55"];
let NsStageHiScoreReimuEEasy2=["505","500.11","500.22","500.33","500.44","500.55"];

let NsStageHiScoreReimuANormal=["110","110.1","110.2","110.3","110.4","110.5"];
let NsStageHiScoreReimuBNormal=["210","210.1","210.2","210.3","210.4","210.5"];
let NsStageHiScoreReimuCNormal=["310","310.1","310.2","310.3","310.4","310.5"];
let NsStageHiScoreReimuDNormal=["410","410.1","410.2","410.3","410.4","410.5"];
let NsStageHiScoreReimuENormal=["510","510.1","510.2","510.3","510.4","510.5"];

let NsStageHiScoreReimuANormal2=["115","110.11","110.22","110.33","110.44","110.55"];
let NsStageHiScoreReimuBNormal2=["215","210.11","210.22","210.33","210.44","210.55"];
let NsStageHiScoreReimuCNormal2=["315","310.11","310.22","310.33","310.44","310.55"];
let NsStageHiScoreReimuDNormal2=["415","410.11","410.22","410.33","410.44","410.55"];
let NsStageHiScoreReimuENormal2=["515","510.11","510.22","510.33","510.44","510.55"];

let NsStageHiScoreReimuAHard=["120","120.1","120.2","120.3","120.4","120.5"];
let NsStageHiScoreReimuBHard=["220","220.1","220.2","220.3","220.4","220.5"];
let NsStageHiScoreReimuCHard=["320","320.1","320.2","320.3","320.4","320.5"];
let NsStageHiScoreReimuDHard=["420","420.1","420.2","420.3","420.4","420.5"];
let NsStageHiScoreReimuEHard=["520","520.1","520.2","520.3","520.4","520.5"];

let NsStageHiScoreReimuAHard2=["125","120.11","120.22","120.33","120.44","120.55"];
let NsStageHiScoreReimuBHard2=["225","220.11","220.22","220.33","220.44","220.55"];
let NsStageHiScoreReimuCHard2=["325","320.11","320.22","320.33","320.44","320.55"];
let NsStageHiScoreReimuDHard2=["425","420.11","420.22","420.33","420.44","420.55"];
let NsStageHiScoreReimuEHard2=["525","520.11","520.22","520.33","520.44","520.55"];

let NsStageHiScoreReimuALuna=["130","130.1","130.2","130.3","130.4","130.5"];
let NsStageHiScoreReimuBLuna=["230","230.1","230.2","230.3","230.4","230.5"];
let NsStageHiScoreReimuCLuna=["330","330.1","330.2","330.3","330.4","330.5"];
let NsStageHiScoreReimuDLuna=["430","430.1","430.2","430.3","430.4","430.5"];
let NsStageHiScoreReimuELuna=["530","530.1","530.2","530.3","530.4","530.5"];

let NsStageHiScoreReimuALuna2=["135","120.11","130.22","130.33","130.44","130.55"];
let NsStageHiScoreReimuBLuna2=["235","230.11","230.22","230.33","230.44","230.55"];
let NsStageHiScoreReimuCLuna2=["335","330.11","330.22","330.33","330.44","330.55"];
let NsStageHiScoreReimuDLuna2=["435","430.11","430.22","430.33","430.44","430.55"];
let NsStageHiScoreReimuELuna2=["535","530.11","530.22","530.33","530.44","530.55"];


let NsHiScoreEasyName=["SEN1","SEN2","SEN3","SEN4","SEN5","SEN6","SEN7","SEN8","SEN9","SEN10"];
let NsHiScoreNormalName=["SNN1","SNN2","SNN3","SNN4","SNN5","SNN6","SNN7","SNN8","SNN9","SNN10"];
let NsHiScoreHardName=["SHN1","SHN2","SHN3","SHN4","SHN5","SHN6","SHN7","SHN8","SHN9","SHN10"];


let NsStageHiScoreEasyName=["SSEN1","SSEN2","SSEN3","SSEN4","SSEN5"];
let NsStageHiScoreNormalName=["SSNN1","SSNN2","SSNN3","SSNN4","SSNN5"];
let NsStageHiScoreHardName=["SSHN1","SSHN2","SSHN3","SSHN4","SSHN5"];


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

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

let NsFrequencyReimuCEasy = "F_RC_E";
let NsFrequencyReimuCNormal = "F_RC_N";
let NsFrequencyReimuCHard = "F_RC_H";
let NsFrequencyReimuCLuna = "F_RC_L";

let NsFrequencyReimuDEasy = "F_RD_E";
let NsFrequencyReimuDNormal = "F_RD_N";
let NsFrequencyReimuDHard = "F_RD_H";
let NsFrequencyReimuDLuna = "F_RD_L";

let NsFrequencyReimuEEasy = "F_RE_E";
let NsFrequencyReimuENormal = "F_RE_N";
let NsFrequencyReimuEHard = "F_RE_H";
let NsFrequencyReimuELuna = "F_RE_L";

let NsAllScore = "ALL_SCORE";
let NsAllScore2 = "ALL_SCORE2";
let NsAllScore3 = "ALL_SCORE3";

let NsAllFragment = "ALL_FRAGMENT";
let NsAllFragment2 = "ALL_FRAGMENT2";

let NsAllDeadNum = "ALL_DEEDNUM";

let NsAchievement=[];
ascent(i in 0..100)
{
NsAchievement=NsAchievement~["Achievement_"~NumToStringNoComplete(i)];
}

/*
let NsAchievement=["Achievement_0","Achievement_1","Achievement_2","Achievement_3","Achievement_4",
		"Achievement_5","Achievement_6","Achievement_7","Achievement_8","Achievement_9",
		"Achievement_10","Achievement_11","Achievement_12","Achievement_13","Achievement_14",
		"Achievement_15","Achievement_16","Achievement_17","Achievement_18","Achievement_19",
		"Achievement_20","Achievement_21","Achievement_22","Achievement_23","Achievement_24",
		"Achievement_25","Achievement_26","Achievement_27","Achievement_28","Achievement_29"];
*/
let NsContinueCount = "CONTINUW_COUNT";
//////////////////////////////////////////////////////////////////////////////////////////

// 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);//共通データに変更後の配列を渡す
}

function DrawNameText(name,x,y,size,alpha)
{
	let nameleng=length(name);
	if(name[nameleng-4]=="."[0])
	{
	loop(4)
	{
	name=erase(name,nameleng-4);
	}
	}
	DrawText(name,x,y,size,alpha);
}

///////////////////////////////////////////////////////////////////////////////////////////
	let csd = GetCurrentScriptDirectory;
	let imgLetter =csd ~ "img/border.png"; 
	let DefinedPlayer1="MarisaA.txt";
	let DefinedPlayer2="MarisaB.txt";
	let DefinedPlayer3="MarisaC.txt";
	let DefinedPlayer4="MarisaD.txt";
	let DefinedPlayer5="OtherPlayers";

//	let DedinedPlayerArray=[DefinedPlayer1,DefinedPlayer2,DefinedPlayer3,DefinedPlayer4];
	let SelectedCharacter=GetPlayerScriptName;

	if(SelectedCharacter!="MarisaA.txt" &&
	SelectedCharacter!="MarisaB.txt"&&
	SelectedCharacter!="MarisaC.txt"&&
	SelectedCharacter!="MarisaD.txt")
	{
		SelectedCharacter="OtherPlayers"
	}


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

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

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];//文字列をスライシングして返す
	}

	function NumToStringNoComplete(let num)
	{
		if(num==0)
		{
			num=0.1;
		}
		let leng = trunc(log10(num))+1;//整数部分の桁数を求める
		let string = ToString(num);//数字を文字列に変える
		return string[0..leng];//文字列をスライシングして返す
	}

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

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],255,255,255,255);
		}
	}
	if(num[0]==0)
	{
		DisplayNumLetter(x,y,0,255,255,255,255);
	}
}


task DisPlayScoreNumberAno(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);

let digit=1;
if(number2!=0)
{
	digit=6;
}
else
{
	descent(i in 1..7)
	{
		if(num[i]!=0 && digit==1)
		{
			digit=i;
		}
	}
}
let vertex=6*digit;
let dx=20;
		let scx=0.6;
		let scy=0.6;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgNumber);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLELIST);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, vertex);
		ascent(i in 0..digit)
		{
		ObjEffect_SetVertexXY(obj, 0+i*6, -13-i*dx, -16);
		ObjEffect_SetVertexXY(obj, 1+i*6, 13-i*dx,  -16);
		ObjEffect_SetVertexXY(obj, 2+i*6, -13-i*dx, 16);
		ObjEffect_SetVertexXY(obj, 3+i*6,  13-i*dx,  16);
		ObjEffect_SetVertexXY(obj, 4+i*6, 13-i*dx, -16);
		ObjEffect_SetVertexXY(obj, 5+i*6,  -13-i*dx,  16);
		
		ObjEffect_SetVertexUV(obj, 0+i*6,  0+40*num[i+1],  6);
		ObjEffect_SetVertexUV(obj, 1+i*6,  26+40*num[i+1], 6);
		ObjEffect_SetVertexUV(obj, 2+i*6, 0+40*num[i+1],  38);
		ObjEffect_SetVertexUV(obj, 3+i*6, 26+40*num[i+1], 38);
		ObjEffect_SetVertexUV(obj, 4+i*6, 26+40*num[i+1], 6);
		ObjEffect_SetVertexUV(obj, 5+i*6, 0+40*num[i+1], 38);
		}

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

}

task DisPlayScoreNumber2Ano(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);

let digit=0;
	descent(i in 1..7)
	{
		if(num[i]!=0 && digit==0)
		{
			digit=i;
		}
	}
let vertex=6*digit;
let dx=20;
		let scx=0.6;
		let scy=0.6;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgNumber);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLELIST);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, vertex);
		ascent(i in 0..digit)
		{
		ObjEffect_SetVertexXY(obj, 0+i*6, -13-i*dx, -16);
		ObjEffect_SetVertexXY(obj, 1+i*6, 13-i*dx,  -16);
		ObjEffect_SetVertexXY(obj, 2+i*6, -13-i*dx, 16);
		ObjEffect_SetVertexXY(obj, 3+i*6,  13-i*dx,  16);
		ObjEffect_SetVertexXY(obj, 4+i*6, 13-i*dx, -16);
		ObjEffect_SetVertexXY(obj, 5+i*6,  -13-i*dx,  16);
		
		ObjEffect_SetVertexUV(obj, 0+i*6,  0+40*num[i+1],  6);
		ObjEffect_SetVertexUV(obj, 1+i*6,  26+40*num[i+1], 6);
		ObjEffect_SetVertexUV(obj, 2+i*6, 0+40*num[i+1],  38);
		ObjEffect_SetVertexUV(obj, 3+i*6, 26+40*num[i+1], 38);
		ObjEffect_SetVertexUV(obj, 4+i*6, 26+40*num[i+1], 6);
		ObjEffect_SetVertexUV(obj, 5+i*6, 0+40*num[i+1], 38);
		}

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

}

task DisPlayDigitNumber(let x,let y,let number)
{
number+=12;
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(num[2]!=0){x+=ScoreNumberXpx-1;}
	ascent(let i in 1..7)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,num[i],255,255,255,128);
		}
	}
	if(num[0]==0)
	{
		DisplayNumLetter(x,y,0,255,255,255,128);
	}
}

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

	let DrawDigit=denomination;
	x+=denomination*ScoreNumberXpx;

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


task DisPlayScoreNumber2(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);

	let DrawDigit=denomination-6;
	if(DrawDigit<0){DrawDigit=0;}
	x+=denomination*12;

	if(denomination>=0 && denomination<=12)
	{
	ascent(let i in 1+DrawDigit..7)
	{
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,num[i],255,255,200,200);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
	}
}

task DisPlayScoreNumber3(let x,let y,let number,let number2)
{
let num=[];
if(number2!=0)
{
	number+=1000000;
}
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);

	let DrawDigit=denomination-12;
	if(DrawDigit<0){DrawDigit=0;}

	x+=denomination*12;
	//x-=5;
	if(denomination>=0 && denomination<=18)
	{
	ascent(let i in 1+DrawDigit..7)
	{
		if(i==denomination+1)
		{
			x-=5;
		}
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,num[i],255,200,255,200);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
	}
}

task DisPlayScoreNumber4(let x,let y,let number,let number2)
{
let num=[];
if(number2!=0)
{
	number+=1000000;
}
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);

	let DrawDigit=denomination-18;
	if(DrawDigit<0){DrawDigit=0;}

	x+=denomination*12;

	if(denomination>=0 && denomination<=24)
	{
	ascent(let i in 1+DrawDigit..7)
	{
		if(i==denomination+1-6)
		{
			x-=5;
		}
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,num[i],255,255,200,255);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
	}
}

task DisPlayScoreNumber5(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);

	let DrawDigit=denomination-24;
	if(DrawDigit<0){DrawDigit=0;}

	x+=denomination*12;

	if(denomination>=0 && denomination<=30)
	{
	ascent(let i in 1+DrawDigit..7)
	{
		if(i==denomination+1-12)
		{
			x-=5;
		}
		if(num[0]>=10^(i-1))
		{
			DisplayNumLetter(x-(i-1)*ScoreNumberXpx,y,num[i],255,128,255,128);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
	}
}

task DisplayNumLetter(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 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 ResultNumberDisPlayFragment(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..7)
	{
		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,scx,scy)
{
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))
	//	{
			if(scx==1)
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B,scx,scy);
			}
			else
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12+(x-(i-1)*12-GetCenterX)*(scx-1),y,num[i],Alpha,R,G,B,scx,scy);
			}

	//	}
	}
	if(scx==1)
	{
	TimeBonusDisplayNumLetter(x-(4-1)*12,y,10,Alpha,R,G,B,scx,scy);
	}
	else
	{
	TimeBonusDisplayNumLetter(x-(4-1)*12+(x-(4-1)*12-GetCenterX)*(scx-1),y,10,Alpha,R,G,B,scx,scy);
	}


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

task BossRateNumDisplay(let x,let y,let number,Alpha,R,G,B,scx,scy)
{
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))
		{
			if(scx==1)
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B,scx,scy);
			}
			else
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12+(x-(i-1)*12-GetCenterX)*(scx-1),y,num[i],Alpha,R,G,B,scx,scy);
			}
		}
	}
		//	TimeBonusDisplayNumLetter(x-(4-1)*12,y,10,Alpha,R,G,B);
	ascent(let i in 4..10)
	{
		if(num[0]>=10^(i-1))
		{
			if(scx==1)
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12,y,num[i],Alpha,R,G,B,scx,scy);
			}
			else
			{
			TimeBonusDisplayNumLetter(x-(i-1)*12+(x-(i-1)*12-GetCenterX)*(scx-1),y,num[i],Alpha,R,G,B,scx,scy);
			}
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
}

task TimeBonusDisplayNumLetter(let x,let y,let num,Alpha,R,G,B,scx,scy)
{
		scx*=0.6;
		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,scx,scy)
{
		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*0.6,scy*0.6);
		if(scx==0.6)
		{
		Obj_SetPosition(obj0,x,y+5);
		}
		else
		{
		Obj_SetPosition(obj0,x+(x-GetCenterX)*(scx-1),y+5);
		}
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task PercentDisplay(let x,let y,Alpha,R,G,B,scx,scy)
{
		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*0.6,scy*0.6);
		if(scx==0.6)
		{
		Obj_SetPosition(obj0,x,y+5);
		}
		else
		{
		Obj_SetPosition(obj0,x+(x-GetCenterX)*(scx-1),y+5);
		}
		ObjEffect_SetLayer(obj0,8);
		wait(1);
		Obj_Delete(obj0);
}

task SubDisPlayScoreNumber(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);

	let DrawDigit=denomination;
	x+=denomination*ScoreNumberXpx;

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

task SubDisPlayScoreNumber2(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);

	let DrawDigit=denomination-6;
	if(DrawDigit<0){DrawDigit=0;}
	x+=denomination*12;

	if(denomination>=0 && denomination<=12)
	{
	ascent(let i in 1+DrawDigit..7)
	{
		if(num[0]>=10^(i-1))
		{
			SubDisplayNumLetter(x-(i-1)*8,y,num[i],255,255,200,200);
		}
	}
	if(num[0]==0)
	{
		//DisplayNumLetter(x,y,0);
	}
	}
}

task SubDisplayNumLetter(let x,let y,let num,Alpha,R,G,B)
{
		let scx=0.4;
		let scy=0.4;
		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);
}

function KeyStateUp
{
	if(GetKeyState(VK_UP)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_UP)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_UP)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_UP)==KEY_FREE){return("FREE");}
}

function KeyStateDown
{
	if(GetKeyState(VK_DOWN)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_DOWN)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_DOWN)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_DOWN)==KEY_FREE){return("FREE");}
}

function KeyStateLeft
{
	if(GetKeyState(VK_LEFT)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_LEFT)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_LEFT)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_LEFT)==KEY_FREE){return("FREE");}
}

function KeyStateRight
{
	if(GetKeyState(VK_RIGHT)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_RIGHT)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_RIGHT)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_RIGHT)==KEY_FREE){return("FREE");}
}

function KeyStateShot
{
	if(GetKeyState(VK_SHOT)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_SHOT)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_SHOT)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_SHOT)==KEY_FREE){return("FREE");}
}

function KeyStateBomb
{
	if(GetKeyState(VK_BOMB)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_BOMB)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_BOMB)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_BOMB)==KEY_FREE){return("FREE");}
}

function KeyStateSlowMove
{
	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_SLOWMOVE)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_SLOWMOVE)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_SLOWMOVE)==KEY_FREE){return("FREE");}
}

function KeyStateSkip
{
	if(GetKeyState(VK_SKIP)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_SKIP)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_SKIP)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_SKIP)==KEY_FREE){return("FREE");}
}

function KeyStateUser
{
	if(GetKeyState(VK_USER)==KEY_PUSH){return("PUSH");}
	if(GetKeyState(VK_USER)==KEY_HOLD){return("HOLD");}
	if(GetKeyState(VK_USER)==KEY_PULL){return("PULL");}
	if(GetKeyState(VK_USER)==KEY_FREE){return("FREE");}
}