Code: Select all
function find_distance(xorigin, yorigin, xdestination, ydestination)
if xorigin > xdestination then
xdistance = xorigin - xdestination
elseif xorigin < xdestination then
xdistance = xdestination - xorigin
end
if yorigin > ydestination then
ydistance = yorigin - ydestination
elseif yorigin < ydestination then
ydistance = ydestination - yorigin
end
return distance = sqrt(xdistance ^ 2 + ydistance ^ 2)
end