Custom functions
Posted: Sun Dec 13, 2009 6:41 am
Is it possible to make my own functions? It's just to shorten certain things (find the distance between 2 sets of coordinates, etc.)
Code: Select all
function love.load()
local x, y, dis
x = 10
y = 5
dis = math.sqrt(math.pow(x,2)+math.pow(y,2))
end
Code: Select all
function love.load()
local dis
dis = distance(10,5)
end
--Finds the distance from the origin to an (x,y) point.
function distance(x, y)
return math.sqrt(math.pow(x,2)+math.pow(y,2))
end