It’s easy to write a pathfinder.
Copy the code The code is as follows: x1, y1) {//Rectangular coordinates tilted 45 degrees
var x0 =0;
var y0 =0;
var s=-Math.PI/4;
var o={} ;
o.x = int((x0 x1*Math.cos(s) y1*Math.sin(s))) dx;
o.y =-int((y0 x1*Math.sin(s)-y1 *Math.cos(s)))/2 dy;
return o;
}
function rot45(x1, y1) {//45 degree oblique rotation to rectangular coordinates
var x0 =0;
var y0 =0;
x1-=dx
y1-=dy
y1*=-2;
var s=-Math.PI/4;
var o= {};
o.x = int((x0 x1*Math.cos(s) y1*Math.sin(s))/dw);
o.y = int((y0 x1*Math.sin(s) -y1*Math.cos(s))/dw);
return o;
}
Just give me a picture, 8 directions, you can change 4 directions