Mothback/code/math.lua
lustlion 236e23177d function to improve entities moving on collisions and fixed accordingly
made math.round()
changed vector() and fixed accordingly
2022-03-16 18:50:10 +01:00

30 lines
446 B
Lua

function math.sign(x)
if x<0 then
return -1
elseif x>0 then
return 1
else
return 0
end
end
function math.round(x)
return math.floor(x+0.5)
end
function vector(x, y)
return {x = x, y = y}
end
function getVectorValue(vector)
return math.sqrt(vector.x ^ 2 + vector.y ^ 2)
end
function getAngleFromVector(vector)
local reduce = 0
if vector.x < 0 then
reduce = math.rad(180)
end
return math.atan(vector.y/vector.x) - reduce
end