function GetCenterX{
	return GetStgFrameWidth/2;
}

function GetCenterY{
	return GetStgFrameHeight/2;
}

function GetStgSize{
	return ((GetStgFrameWidth^2)+(GetStgFrameHeight^2))^0.5;
}

function GetClipMaxX{
	return GetStgFrameWidth;
}

function GetClipMaxY{
	return GetStgFrameHeight;
}

function GetClipMinX{
	return GetStgFrameLeft*0;
}

function GetClipMinY{
	return GetStgFrameTop*0;
}


function rand_negate(v){
	return v-(rand_int(0,1)*(v*2));
}

function wave(m){
	return 0.5+(0.5*sin(270+(180*m)));
}

function GetPointAngle(x1,y1,x2,y2){
	let angle=atan2(y1-y2,x1-x2);
	return angle;
}

function GetDistance(x1,y1,x2,y2){
	return ((x2-x1)^2+(y2-y1)^2)^(1/2);
}

function PosToPan(x,maxrate){
	return maxrate*(-1+(2*(x/GetClipMaxX)));
}

function GetLineBorderPoint(px,py,tx,ty){
    let ta = atan2(ty-py,tx-px);
    if(ta>=atan2(0-py,0-px) && ta<=atan2(0-py,GetClipMaxX-px)){
        return [px-(0-py)*tan(ta+90),0];
    }
    if(ta>=atan2(0-py,GetClipMaxX-px) && ta<=atan2(GetClipMaxY-py,GetClipMaxX-px)){
        return [GetClipMaxX,py+(GetClipMaxX-px)*tan(ta)];
    }
    if(ta>=atan2(GetClipMaxY-py,GetClipMaxX-px) && ta<=atan2(GetClipMaxY-py,0-px)){
        return [px-(GetClipMaxY-py)*tan(ta-90),GetClipMaxY];
    }
    if(ta>=atan2(GetClipMaxY-py,0-px) || ta<=atan2(0-py,0-px)){
        return [0,py+(0-px)*tan(ta+180)];
    }
}

function Homing(toAngle,angle,dAngle){
	toAngle %= 360;
	angle %= 360;

	let ret = toAngle-angle;
	if(ret >= 180){ret -= 360;}
	if(ret < -180){ret += 360;}

	if((|ret|) < dAngle){
		angle = toAngle;
	}else{
		if(sin(ret) > 0){
			angle += dAngle;
		}else{
			angle -= dAngle;
		}
	}
	if(angle >= 360){angle -= 360;}
	if(angle < 0){angle += 360;}

	return angle;
}

function Obj_IsEnemyIntersected(obj){
	let e_count = ObjCol_GetListOfIntersectedEnemyID(obj);
	if(length(e_count)>0){
		return true;
	}else{
		return false;
	}
}

function IsEnemyPresent{
	let enemy = GetEnemyIntersectionPosition(GetPlayerX, GetPlayerY, 1);
	if(length(enemy)>0){return true;}else{return false;}
}

function IsEnemyExist{
	let enemy = GetAllEnemyID;
	if(length(enemy)>0){return true;}else{return false;}
}

function GetAngleToNearestEnemy(x,y,otherwise){
	let pos = GetEnemyIntersectionPosition(x,y,1);
	let angle;
	if(length(pos)>0)
	{
		angle = atan2(pos[0][1]-y,pos[0][0]-x);
	}else{
		angle = otherwise;
	}
	return angle;
}

function GetDistanceToNearestEnemy(x,y,otherwise){
	let pos = GetEnemyIntersectionPosition(x,y,1);
	let dist;
	if(length(pos)>0){
		dist = GetDistance(x,y,pos[0][0],pos[0][1]);
	}else{
		dist = otherwise;
	}
	return dist;
}