假设场景网格如下 数字代表的是坐标 11代表的是x1,y1 46代表的是 x4,y6
11, 12, 13, 14, 15, 16, 17, 18, 19
21, 22, 23, 24, 25, 26, 27, 28, 29
33, 32, 33, 34, 35, 36, 37, 38, 39
41, 42, 43, 44, 45, 46, 47, 48, 49
51, 52, 53, 54, 55, 56, 57, 58, 59
61, 62, 63, 64, 55, 66, 67, 68, 69
71, 72, 73, 74, 75, 76, 77, 78, 79
81, 82, 83, 84, 55, 86, 87, 88, 89
91, 92, 93, 94, 55, 96, 97, 98, 99
那么角色的位置是11 寻路到96呢
11, 12, 13, 14, 15, 16, 17, 18, 19
21, 22, 23, 24, 25, 26, 27, 28, 29
33, 32, 33, 34, 35, 36, 37, 38, 39
41, 42, 43, 44, 45, 46, 47, 48, 49
51, 52, 53, 54, 55, 56, 57, 58, 59
61, 62, 63, 64, 55, 66, 67, 68, 69
71, 72, 73, 74, 75, 76, 77, 78, 79
81, 82, 83, 84, 55, 86, 87, 88, 89
91, 92, 93, 94, 55, 96, 97, 98, 99
这是我们要做的寻路网格,bresenham算法大致先求一轴向,在根据路径长短加令一轴。直接看代码吧erlang版