I want to find the distance between case(n) and case(m), with n!=m, using A* algorithm. How can i find x0, x1, y0 and y1 by using case number, height and width in a maze ? Are there a formule for that ?
float distance(Maze* maze, int start, int end)
{
float x0 = ..??..
float x1 = ..??..
float y0 = ..??..
float y1 = ..??..
float dx = x0 - x1;
float dy = y0 - y1;
return sqrtf(dx*dx+dy*dy);
}
Example of a maze :
<----------- width ------------->
case0 | case1 | case2 | case3 |
case4 | case5 | case6 | case7 | height
case8 | case9 | case10 | case11 |