Its in the zipp....
source if you dont like downloads...
rem
rem AGK Application
rem
#include "AGK Pathfinder.agc"
#include "ide.agc"
SetVirtualResolution(800,600)
setsyncrate(0,0)
setPrintSize(18)
Gosub Initiate_Pathfinder
//For the path drawing control------------------------
Dim PathSprites[1000] As Integer
Global PathSpritesCounter
//----------------------------------------------------
Global img1,spr1,img2,spr2,img3,spr3,img4,spr4,img5,spr5,spr6
Global mouseX,mouseY,mxC,myC,sxC,syC,exC,eyC,selBlock
Global selDiag,Target_Cursor
Global Error$
Global MouseInGrid
Dim DiagText$[2]
global Bottom_Of_Grid
Bottom_Of_Grid = PathFinder_Height* PathFinder_Scale
InitializeVariables()
LoadMedia()
InitializeMap(PathFinder_Width,PathFinder_Height)
DrawGrid(PathFinder_Width,PathFinder_Height,PathFinder_Scale)
DrawButtons()
// The dummy unit to test the pathfinding with
/////////////////////////////////////////////////////////////////////////////////////////////
global UnitMove=0
global UnitX#
global UnitY#
UnitX#=random(0,PathFinder_Width)+0.0
UnitY#=random(0,PathFinder_Height)+0.0
global UnitX
global UnitY
UnitX=UnitX#
UnitY=UnitY#
global UnitAng#=0.0
spr6 = CreateSprite ( img4 )
setspritepositionByOffset(spr6,UnitX# * PathFinder_Scale+(PathFinder_Scale/2),UnitY# * PathFinder_Scale+(PathFinder_Scale/2))
//////////////////////////////////////////////////////////////////////////////////////////////
global GFT#
do
GFT# = GetFrameTime()
mouseX = getpointerx()
mouseY = getpointery()
if mouseX >= 0 and mouseX <= PathFinder_Scale * (PathFinder_Width+1) and mouseY >= 0 and mouseY <= PathFinder_Scale * (PathFinder_Height+1)
mxC = (mouseX / PathFinder_Scale)
myC = (mouseY / PathFinder_Scale)
MouseInGrid=1
else
mxC = 0
myC = 0
MouseInGrid=0
endif
Buttons()
Draw_Entitys()
DebugInfo()
if UnitMove=1
UnitX=UnitX#
UnitY=UnitY#
if UnitX=exC and UnitY=eyC then UnitMove=0
if GetDistance( UnitX#, UnitY#, PathFinder_First_X+0.0,PathFinder_First_Y+0.0)<2.0
PathFinder_Path$ = PathFinder_Search(UnitX, UnitY, exC, eyC, selDiag, 1000)
ClearPath()
DrawPath(PathFinder_Path$)
UnitAng#=Point_TO(UnitX#,UnitY#,PathFinder_First_X,PathFinder_First_Y)-90
SetSpriteAngle(spr6,UnitAng#+90)
endif
if UnitMove=1
UnitX#=UnitX# + (cos(UnitAng#) * (6.0*GFT#))
UnitY#=UnitY# + (sin(UnitAng#) * (6.0*GFT#))
setspritepositionByOffset(spr6,UnitX# * PathFinder_Scale+(PathFinder_Scale/2),UnitY# * PathFinder_Scale+(PathFinder_Scale/2))
endif
endif
print("test = "+str( PathFinder_First_X )+" "+str(PathFinder_First_Y) )
// escape on computer and back button on device
if GetRawKeyState(27)=1 then end
Sync()
loop
Function GetDistance( x#, y#, x2#, y2#)
d# = sqrt( ((x# - x2#)^2) + ((y# - y2#)^2) )
Endfunction d#
function Point_TO(x#,y#,x2#,y2#)
new_angle# = atanfull(x2#-x#,y2#-y#)
endfunction new_angle#
Function DrawPath(Path$)
If PathSpritesCounter > 0 Then ClearPath()
PathSpritesCounter = 0
PathX = 0
PathY = 0
PathAux$ = ""
PathAlter = 0
REM // Remember that the path is drawed in reversed order (end to start)
For i = 1 to Len(Path$)-1
If Mid(Path$,i,1) = "," Or i = Len(Path$)
If PathAlter = 0
PathX = Val(PathAux$)
PathAlter = 1 - PathAlter
PathAux$ = ""
Else
If i = Len(Path$) Then PathAux$ = PathAux$ + Mid(Path$,i,1)
PathY = Val(PathAux$)
PathAlter = 1 - PathAlter
PathAux$ = ""
crazy1 = (PathX) * PathFinder_Scale
crazy2 = (PathY) * PathFinder_Scale
clonedSprite = CloneSprite ( spr3 )
SetSpritePosition(clonedSprite, crazy1, crazy2)
PathSprites[PathSpritesCounter] = clonedSprite
PathSpritesCounter = PathSpritesCounter + 1
EndIf
Else
PathAux$ = PathAux$ + Mid(Path$,i,1)
EndIf
Next i
EndFunction
Function ClearPath()
If PathSpritesCounter = 0 Then exit
For cp = 0 to PathSpritesCounter - 1
If PathSprites[cp] > -1
DeleteSprite(PathSprites[cp])
PathSprites[cp]=-1
EndIf
Next
EndFunction
function DrawGrid(columns,rows,tsize)
for x = 0 to columns
for y = 0 to rows
clonedSprite = CloneSprite ( spr1 )
SetSpritePosition ( clonedSprite, x * tsize, y * tsize)
next y
next x
endfunction
function InitializeMap(columns,rows)
for x = 0 to columns
for y = 0 to rows
If PathFinder_Solid[columns,rows]>0
auxsprite = PathFinder_Solid[columns,rows]
DeleteSprite( auxsprite )
PathFinder_Solid[columns,rows]=0
EndIf
next y
next x
endfunction