Ok, here is a modified script to show the path.
hit any key to show the path.
uses "CONSOLE"
randomize
DECLARE function SetupMap LIB "path.DLL" ALIAS "SetupMap" (byval arrayhandle as long, byval Width as long, byval Height as long, byval Diag as long) as long
DECLARE function FindPath LIB "path.DLL" ALIAS "FindPath" (byval StartX as long, byval StartY as long, byval DestX as long, byval DestY as long) as long
DECLARE function GetRoute LIB "path.DLL" ALIAS "GetRoute" ( length as long) as long '// its byref
Console_SetScreenBufferSize(80,25)
const _SIZE as long = 100
dim pMapArr as long
pMapArr = heap_alloc(_size * _size * sizeof(LONG)) '---<<<< ALLOCATE memory
dim i,j as integer
dim arr(_SIZE,_SIZE) as single at pMapArr
dim a,b,c,d,e as long
dim g as long = 1
a=_SIZE
b=_SIZE
c=2
'// Create test map with random val [0.0,1.0]
for i = 1 to _SIZE
for j = 1 to _SIZE
arr(i,j) = rndf(0,1.3) '// a value of >=1 is considered a wall, < 1 is difficulty
next
next
print SetupMap(pMapArr,_SIZE,_SIZE,2) , $crlf '// pass the map
sleep(500)
''for g=1 to 99999
FindPath(1,1, 50,20)'rnd(1,_SIZE-1), rnd(1,_SIZE-1) )
'' if mod(g, 100) = 0 then printl g & " findpath calls." '// call pathfinder
''next
sleep(500)
d=GetRoute(e) '// [e] is length of the route, [d] is the array pointer
print e, $crlf
dim f(e) as long at d '// create an array of [e] size and point to addr [d]
print f(1), f(2)
for i= 1 to _size
for j = 1 to _size
console_printat(".",i,j)
next
next
dim II as long = 1
while ii < e
console_printat("*",f(ii),f(ii+1))
ii+=2
sleep(300)
wend
waitkey
Bookmarks