From 26b955fee837354f9dded81a3349ce996700bb82 Mon Sep 17 00:00:00 2001 From: Andrew Ardill Date: Wed, 10 Jul 2013 13:39:46 +1000 Subject: [PATCH] world.js: Increase functionality of getDistance Allow passing 'from' and 'to' positions to getDistance to find the distance between them. --- script/world.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/script/world.js b/script/world.js index 5dbde21..7534d80 100644 --- a/script/world.js +++ b/script/world.js @@ -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() {