Moving along a path

BlitzMax Forums/BlitzMax Programming/Moving along a path

therevills(Posted 2008) [#1]
Hi All,

Im trying to move a sprite along a path found using a pathfinder routine, but having troubles.

I cant get my sprite to move along the path correctly.

Here is the pathfinder code:




Ive tried this:
If x < TPathfinder.Route[currentPath] * TILE_SIZE + 5
x:+1
endif
if x > TPathfinder.Route[currentPath] * TILE_SIZE + 5
x:-1
endif
if x = TPathfinder.Route[currentPath] * TILE_SIZE + 5
currentPath:-1
endif

But it doesnt work right!

Does any have a good solution for this? I have seen a lot of examples how to create paths but not how to move along them.


therevills(Posted 2008) [#2]
Dont worry, Ive worked out what I was doing wrong...

I was setting the starting currentPath incorrectly, it should be this:

sprite.currentpath = (TPathfinder.Paths - 1) * 2

and with the movement code:

if x = TPathfinder.Route[currentPath] * TILE_SIZE + 5
 currentPath:-2 ' as it store x and y
endif



therevills(Posted 2008) [#3]
Here is a quick example for anyone with the same problem:



Thanks to Curtastic for the great pathfinding code!


therevills(Posted 2008) [#4]
And here is a prototype that I have been working on using the platformer game as a basis:



You can see that I have added ladders, and now you control "Gripe" by using the mouse, just click just above the floor and if "he" can get there he will... Ive made it if you want him to fall you need to click over edge.

http://therevillsjunk.googlepages.com/pathfinderPlatformer.zip

Does any know how to make the pathfinder calculate a path including the fall?