diff --git a/gamecore/utils/math.lua b/gamecore/utils/math.lua index 4168c6b..1c29373 100644 --- a/gamecore/utils/math.lua +++ b/gamecore/utils/math.lua @@ -40,6 +40,16 @@ function Math.round(num) return math.floor(num + 0.5) end +function Math.toZero(num, sub) + local sub = math.floor(sub) + + if math.abs(num) < sub then + return 0 + else + return num - (sub * Math.sign(num)) + end +end + -- VECTOR/DIRECTION functions -- Easy-to-use function to handle point and motion