// Variables
var lerpThread = null
var lerpList = []
/// Name: Math
/// Description: This script holds math functions that will come in handy when doing algorithms
function
/// Name: toRadians
/// Description: Converts a degrees number to radiansformat
/// Params:
/// deg - The number the convert to radians
/// returns - deg in terms of radians
toRadians(deg)
return deg * Math.PI / 180
/// Name: toDegrees
/// Description: Converts a radians number to degrees format
/// Params:
/// rad - The number the convert to degrees
/// returns - rad in terms of degrees
toDegrees(rad)
return rad * 180 / Math.PI
/// Name: lerp
/// Description: Lerps between two values
/// Params:
/// obj - The object who owns the start variable.
/// start - The string variable to start lerping at
/// end - The value that start should reach
/// time - The rate at which it should lerp (1 = faster, 0 = slower) [WARNING: VALUES ABOVE 1 ARE NOT SUPPORTED]
/// _diff (optional) - The difference between start and end where it should snap to end
lerp(obj, start, end, time, _diff)
if(!_diff)
_diff = 0.001
lerpList.push([obj, start, end, time])
if(lerpThread != null)
return
lerpThread = thread(1000/60)
var index = 0
foreach(var lerpVars in lerpList)
obj = lerpVars[0]
start = obj[lerpVars[1]]
end = lerpVars[2]
time = lerpVars[3]
aMes(start)
if(diff(start, end) > _diff)
obj[lerpVars[1]] = start + time * (end - start)
else
obj[lerpVars[1]] = end
lerpList.splice(index, 1)
if(lerpList.length <= 0)
Event.interruptThread(lerpThread)
index++
/// Name: diff
/// Description: Gets the difference between two numbers
/// Params:
/// val1 - The first number
/// val2 - The second number
/// returns - The difference between the two numbers
diff(val1, val2)
return Math.abs(val1 - val2)
// Variables var lerpThread = null var lerpList = [] /// Name: Math /// Description: This script holds math functions that will come in handy when doing algorithms function /// Name: toRadians /// Description: Converts a degrees number to radiansformat /// Params: /// deg - The number the convert to radians /// returns - deg in terms of radians toRadians(deg) return deg * Math.PI / 180 /// Name: toDegrees /// Description: Converts a radians number to degrees format /// Params: /// rad - The number the convert to degrees /// returns - rad in terms of degrees toDegrees(rad) return rad * 180 / Math.PI /// Name: lerp /// Description: Lerps between two values /// Params: /// obj - The object who owns the start variable. /// start - The string variable to start lerping at /// end - The value that start should reach /// time - The rate at which it should lerp (1 = faster, 0 = slower) [WARNING: VALUES ABOVE 1 ARE NOT SUPPORTED] /// _diff (optional) - The difference between start and end where it should snap to end lerp(obj, start, end, time, _diff) if(!_diff) _diff = 0.001 lerpList.push([obj, start, end, time]) if(lerpThread != null) return lerpThread = thread(1000/60) var index = 0 foreach(var lerpVars in lerpList) obj = lerpVars[0] start = obj[lerpVars[1]] end = lerpVars[2] time = lerpVars[3] aMes(start) if(diff(start, end) > _diff) obj[lerpVars[1]] = start + time * (end - start) else obj[lerpVars[1]] = end lerpList.splice(index, 1) if(lerpList.length <= 0) Event.interruptThread(lerpThread) index++ /// Name: diff /// Description: Gets the difference between two numbers /// Params: /// val1 - The first number /// val2 - The second number /// returns - The difference between the two numbers diff(val1, val2) return Math.abs(val1 - val2)