Friday, February 26, 2010

AStarPathfinder

I've created an extensible and fairly simple implementation of A* pathfinding for the PandaXNA engine.

Video:
http://www.screentoaster.com/watch/stWE5RRUdIR19YQVRfWllcUVJc/simple_a_pathfinding

Here is the class:
http://mage360.pastebin.com/34xSMVby

Here is the implementation in Gnome Mountain:
http://mage360.pastebin.com/2QaAgT9p

Example of usage:

pathFinder = new GnomePathfinder(world);
pathFinder.initialise(worldRect.Width, worldRect.Height);

testPath = pathFinder.generatePath(new Vector2(0, 49), new Vector2(3, 35));

In case anybody is wondering about the basic theory behind A* pathfinding, here is a cool tutorial I found lying around the internet. It's very easy to understand and very informative: http://www.policyalmanac.org/games/aStarTutorial.htm

No comments:

Post a Comment