world.js: Increase functionality of getDistance

Allow passing 'from' and 'to' positions to getDistance to find the distance
between them.
This commit is contained in:
Andrew Ardill
2013-07-10 13:39:46 +10:00
parent c4afe143a9
commit 26b955fee8
+4 -2
View File
@@ -419,8 +419,10 @@ var World = {
}
},
getDistance: function() {
return Math.abs(World.curPos[0] - World.RADIUS) + Math.abs(World.curPos[1] - World.RADIUS);
getDistance: function(from, to) {
from = from || World.curPos;
to = to || World.VILLAGE_POS;
return Math.abs(from[0] - to[0]) + Math.abs(from[1] - to[1]);
},
getTerrain: function() {