note: you don't state the co-ordinates of $pos, which makes it hard to know exactly what 10 units means.

Is the 'distance':

A. along the grid's two axis, measure along the X axis then measure along the Y axis.

B. as the crow-flies, measure direct distance between two points.

Both methods start off the same way:

1. If the X or Y axis of the two points is the same value then you only need to calculate the absolute difference between the two points for the axis that isn't the same.

eg. if the X axis of the two points is the same value then you calculate the 'distance' as

`distance = Math.abs(Y1 - Y2)`

2. If neither the X or Y axis is the same for the two points then you first calculate the above for both the X and Y axis...

```
distanceX = Math.abs(X1 - X2)
distanceY = Math.abs(Y1 - Y2)
```

... then to calculate the overall distance you either.

2a. Add the distanceX and distanceY together.

`distance = distanceX + distanceY`

2b. Use distanceX and distanceY to calculate the hypotenuse (x2 + y2 = z2) of a right angle triangle.

`distance = Math.sqrt(Math.pow(distanceX, 2) + Math.pow(distanceY, 2))`