loveutils: add back the wrap function
This commit is contained in:
parent
421e92f80a
commit
091210df41
1 changed files with 16 additions and 0 deletions
|
@ -1,5 +1,21 @@
|
|||
local Math = {}
|
||||
|
||||
function Math.wrap(x, startnumber, endnumber)
|
||||
local delta = endnumber - startnumber
|
||||
if delta < 0 then
|
||||
err("endnumber must be larger than startnumber")
|
||||
end
|
||||
while x >= endnumber do
|
||||
x = x - delta
|
||||
end
|
||||
|
||||
while x < startnumber do
|
||||
x = x + delta
|
||||
end
|
||||
|
||||
return x
|
||||
end
|
||||
|
||||
function Math.sign(x)
|
||||
if (x < 0) then
|
||||
return -1
|
||||
|
|
Loading…
Reference in a new issue