Previous topic - Next topic

Richard Rae

How would I use findpath.I want to click on a square on a 9x9 grid (with a sprite in it),then click on another square in the grid and find out if there is a path to it and move the sprite clicked on first to move to the grid sqare clicked on second.Hope you can help.

Kitty Hello

Code (glbasic) Select
DIM map[9][9]initialize the 9x9 array, so that passable blocks have value>0 and non-passable blocks have value <= 0

Next, add some code for clicking start-endpoint and set the start point into variables:
and the end-point in

Then call:
Code (glbasic) Select
good = FINDPATH(map[], solution[], 0,  sx,sy,  ex,ey)

IF good
   PRINT "Path found!", 0, 0
   PRINT "Path not found", 0, 0
Is that what you need?