Manhattan Distance between tiles in a hexagonal grid

前端 未结 6 926
北海茫月
北海茫月 2020-12-08 07:57

For a square grid the euclidean distance between tile A and B is:

distance = sqrt(sqr(x1-x2)) + sqr(y1-y2))

For an actor constrained to mo

6条回答
  •  情深已故
    2020-12-08 08:48

    This sounds like a job for the Bresenham line algorithm. You can use that to count the number of segments to get from A to B, and that will tell you the path distance.

提交回复
热议问题