function to improve entities moving on collisions and fixed accordingly
made math.round() changed vector() and fixed accordingly
This commit is contained in:
@@ -8,20 +8,22 @@ function math.sign(x)
|
||||
end
|
||||
end
|
||||
|
||||
function vector(init_x, init_y, final_x, final_y)
|
||||
local distance_x = final_x - init_x
|
||||
local distance_y = final_y - init_y
|
||||
return {distance_x, distance_y}
|
||||
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[1] ^ 2 + vector[2] ^ 2)
|
||||
return math.sqrt(vector.x ^ 2 + vector.y ^ 2)
|
||||
end
|
||||
|
||||
function getAngleFromVector(x,y)
|
||||
function getAngleFromVector(vector)
|
||||
local reduce = 0
|
||||
if x < 0 then
|
||||
if vector.x < 0 then
|
||||
reduce = math.rad(180)
|
||||
end
|
||||
return math.atan(y/x) - reduce
|
||||
return math.atan(vector.y/vector.x) - reduce
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user