UNPKG
@2d-game-grid/square
Version:
latest (2.4.3)
2.4.3
2.4.2
2.4.1
2.4.0
2.3.1
2.2.10
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.1
2.1.0
2.0.1
2.0.0
1.0.7
A simple square grid made for games
github.com/mstuercke/2d-game-grid
mstuercke/2d-game-grid
@2d-game-grid/square
/
dist
/
esm
/
algorithms
/
distance
/
manhattanDistance.js
9 lines
(8 loc)
•
257 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
/** *
@param
start The start coordinate *
@param
end The end coordinate *
@returns
The distance between the given coordinates */
export
function
manhattanDistance
(
start, end
) {
return
Math
.
abs
(start.
row
- end.
row
) +
Math
.
abs
(start.
col
- end.
col
); }