Remove redundant classes & added some Position methods.

This commit is contained in:
BenDol
2014-06-10 01:44:03 +12:00
parent 99b1ddf44c
commit ce9e443c60
3 changed files with 12 additions and 114 deletions

View File

@@ -22,4 +22,16 @@ end
function Position.isInRange(pos1, pos2, xRange, yRange)
return math.abs(pos1.x-pos2.x) <= xRange and math.abs(pos1.y-pos2.y) <= yRange and pos1.z == pos2.z;
end
function Position.isValid(pos)
return not (pos.x == 65535 and pos.y == 65535 and pos.z == 255)
end
function Position.distance(pos1, pos2)
return math.sqrt(math.pow((pos2.x - pos1.x), 2) + math.pow((pos2.y - pos1.y), 2))
end
function Position.manhattanDistance(pos1, pos2)
return math.abs(pos2.x - pos1.x) + math.abs(pos2.y - pos1.y)
end