Advertisement
billysback

distance thingy

Jul 17th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.41 KB | None | 0 0
  1.  
  2. local function getDist(x1, y1, x2, y2)
  3.     --local dist = math.sqrt( (math.abs(x1-x2) ^ 2) + (math.abs(y1-y2) ^ 2) )
  4.     local minDist = math.floor( math.sqrt( (math.abs(x1-x2-1) ^ 2) + (math.abs(y1-y2-1) ^ 2) ) )
  5.     local maxDist = math.floor( math.sqrt( (math.abs(x1-x2+1) ^ 2) + (math.abs(y1-y2+1) ^ 2) ) )
  6.     print("min = "..minDist.. ", max = "..maxDist)
  7.     local dist = math.random(minDist, maxDist)
  8.     return dist
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement