I have been working in a pathfinding routine and this is what I have so far:
speed=5
`wall
ink rgb(0,0,255),0
box 10,10,20,100
get image 1,11,10,25,100
cls
`vars
x=306
y=285
`guy
ink rgb(255,255,255),0
box 10,10,20,20
get image 2,10,10,20,20
cls
sprite 2,x,y,2
`goal
ink rgb(255,255,255),0
box 10,10,20,20
get image 2,10,10,20,20
cls
`waypoints
ink rgb(0,255,0),0
box 10,10,20,20
get image 3,10,10,20,20
cls
sync on:sync rate 15:hide mouse
ink rgb(255,255,255),0
do
cls
sprite 1,screen width()/2,screen height()/2,1
sprite 3,334,285,2
oldx=x
oldy=y
if diry=0:y=y-speed:endif
if diry=1:y=y+speed:endif
if dirx=0:x=x-speed:endif
if dirx=1:x=x+speed:endif
sprite 2,x,y,2
`waypoints (up)
sprite 4,306,227,3
sprite 5,334,227,3
`waypoints (down)
sprite 6,306,334,3
sprite 7,334,334,3
if sprite collision(1,2)=<0:Print "walkable":else:print "unwalkable":endif
Print "X:";x
Print "Y:";y
if x<334:dirx=1:endif
if x=>334 and y<285:x=oldx:diry=1:endif
if x=>334 and y>285:x=oldx:diry=0:endif
if x=>334 and y=>285:x=oldx:y=oldy:Print "founded":endif
if sprite collision(1,2)>0 and d=67:x=oldx:endif
d=sqrt((screen height()/2-306)^2 + (screen width()/2-334)^2)
sync
loop
But it isn't effective at all. I had read IanM's pathfinding code but I didn't understand it and it's for DBPro,I have DBC.
If somebody can help to make a better routine,please post.
Thanks!
CURRENT PROJECT: RETRO PAC-MAN