All pastes #166336 Raw Edit

Stuff

public java v1 · immutable
·published 2006-09-10 20:19 UTC
rendered paste body
    public int getExactDistanceFrom(Tile comparisonPos) {        int comparisonX = comparisonPos.getX(),            comparisonY = comparisonPos.getY();        int stepsCount = 0;                while(!(comparisonX == x || comparisonY == y)) {            if(comparisonX > x)                comparisonX--;            else if(comparisonX < x)                comparisonX++;                        if(comparisonY > y)                comparisonY--;            else if(comparisonY < y)                comparisonY++;            stepsCount++;        }                if(comparisonX == x)            stepsCount += Math.abs(comparisonX - x);        else if(comparisonY == y)            stepsCount += Math.abs(comparisonY - y);        return stepsCount;    }