function CreateObj(texture, layer)
{
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, texture);
	ObjEffect_SetLayer(obj, layer);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	return obj;
}
let textimg=GetCurrentScriptDirectory~"ascii.png";
let skipcount=0;

LoadGraphic(textimg);
function SetXY(id, left, top, right, bottom)
{
	ObjEffect_SetVertexXY(id, 0, left, top);
	ObjEffect_SetVertexXY(id, 1, right, top);
	ObjEffect_SetVertexXY(id, 2, left, bottom);
	ObjEffect_SetVertexXY(id, 3, right, bottom);
}

function SetUV(id, left, top, right, bottom)
{
	ObjEffect_SetVertexUV(id, 0, left, top);
	ObjEffect_SetVertexUV(id, 1, right, top);
	ObjEffect_SetVertexUV(id, 2, left, bottom);
	ObjEffect_SetVertexUV(id, 3, right, bottom);
}

function DrawBonusNum(number,x,y,align,scale){
let stringarray = "";
	if(align=="1P"){
	stringarray = ToFormatz(number,5);
	} else {
	stringarray = ToFormatz(number,7);
	}
	let drawnshit = [];
	let startx = x;
	let starty = y;
	if(align == "POWER"){
		if(length(stringarray)==1){
		stringarray="0"~stringarray;
		
		}
	
	
	}
	ascent(i in 0..length(stringarray)){
		let obj = CreateObj(textimg,8);
		if(stringarray[i]=='0'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,1,215,12,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='1'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,18,215,29,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='2'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,34,215,45,231);
			Obj_SetPosition(obj,startx,starty);
		if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='3'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,50,215,61,231);
			Obj_SetPosition(obj,startx,starty);
		if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='4'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,66,215,78,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='5'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,81,215,92,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='6'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,99,215,110,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='7'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,114,215,125,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='8'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,130,215,141,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]=='9'){
			SetXY(obj,-11,-15.5,11,15.5);
			SetUV(obj,146,216,157,231);
			Obj_SetPosition(obj,startx,starty);
			if(align=="RIGHT"){
			startx-=22;
			} else {
			startx+=22*scale;
			}
		} else if(stringarray[i]==','|| stringarray[i]=='.'){
			SetXY(obj,-8,-8,8,8);
			SetUV(obj,232,225,238,231);
			Obj_SetPosition(obj,startx,starty+15*scale);
			if(align=="RIGHT"){
			startx-=14;
			} else {
			startx+=14*scale;
			}
		}
		ObjEffect_SetScale(obj,scale,scale);
		drawnshit=drawnshit~[obj];
	}
	return drawnshit;
}
function resetNum(array){
	ascent(i in 0..length(array)){Obj_Delete(array[i]);}

}
function ToFormatz(n,wat){
	let dummystring = ToString(n);
	let dummystring2 = "";
	loop(wat){
		dummystring = erase(dummystring,(length(dummystring)-1));
	}
	if(wat == 7){
	ascent(i in 0..length(dummystring)){
		if((length(dummystring)-i)%3==0 && i!=0){
			dummystring2 = dummystring2 ~ ",";
		}
		if(i==0){
			dummystring2 = ToString(dummystring[0]);
		}else{
			dummystring2 = dummystring2 ~ ToString(dummystring[i]);
		}
	}
	return dummystring2;
	} else {
	return dummystring;
	}
}
let livesgfx = [];
let prevlives = 0;
let prevpieces = GetCommonDataDefaultEx("MOF","lifepieces",0);
let lives = GetCurrentScriptDirectory~"system\lives.png";
LoadGraphic(lives);

function DrawLives(grazecombo){
let xpos = 0;
if(GetPlayerLife!=prevlives || GetCommonDataDefaultEx("MOF","lifepieces",0)!=prevpieces){
prevlives = GetPlayerLife;
prevpieces = GetCommonDataDefaultEx("MOF","lifepieces",0);
ascent(i in 0..length(livesgfx)){
Obj_Delete(livesgfx[i]);

}
ascent(i in 0..GetPlayerLife-1){
	let obj = CreateObj(lives,8);
	SetUV(obj,0,1,15,16);
	SetXY(obj,-7.5,-7.5,7.5,7.5);
	Obj_SetPosition(obj,512+i*16,129);
	livesgfx = livesgfx~[obj];
	xpos+=16;

}
if(GetCommonDataDefaultEx("MOF","lifepieces",0)==0){
} else {
let obj = CreateObj(lives,8);
if(GetCommonDataDefaultEx("MOF","lifepieces",0)==4){
	SetUV(obj,16,21,31,36);
	} else if(GetCommonDataDefaultEx("MOF","lifepieces",0)==3){
	SetUV(obj,0,21,15,37);
	} else if(GetCommonDataDefaultEx("MOF","lifepieces",0)==2){
	SetUV(obj,32,1,47,16);
	
	} else if(GetCommonDataDefaultEx("MOF","lifepieces",0)==1){
	SetUV(obj,16,1,31,16);
	
	} else {
	}
	SetXY(obj,-7.5,-7.5,7.5,7.5);
	Obj_SetPosition(obj,512+xpos,129);
	livesgfx = livesgfx~[obj];
}
}

let obj = CreateObj(lives,8);
if(grazecombo>899){
SetUV(obj,0,1,15,16);
} else if(grazecombo>800){
	SetUV(obj,16,21,31,36);
	} else if(grazecombo>600){
	SetUV(obj,0,21,15,37);
	} else if(grazecombo>400){
	SetUV(obj,32,1,47,16);
	
	} else if(grazecombo>200){
	SetUV(obj,16,1,31,16);
	
	} else {
	SetUV(obj,32,21,47,36);
	}
	SetXY(obj,-7.5,-7.5,7.5,7.5);
	Obj_SetPosition(obj,GetClipMinX+100,GetClipMaxY-30);
	ObjEffect_SetScale(obj,1.5,1.5);
	let lol = [obj];
	return lol;
}