by DST » Wed May 12, 2010 10:20 pm
No, i made those paths by hand (programmed the numbers in ).
In retrospect, a level editor would be a better way to do it.
In my newer games, my pathfinding works like this:
All squares start as 0.
The start of the path is square 1.
The next block is square 2, then square 3, and so forth. Turns do not have to be labelled as turns anymore.
All the way up to the final block, at which the creep returns to square 1.
In this way, keep the creep looking for the largest block it can find; at any given point, that will be the next one, whether it is in front or turns.
You can even split paths using this method, where say at block 10, we split into two, so there are 2 block 11's. Program the creep to pick one randomly whenever it finds two of the same number.
So the left path goes from 11-20, but the right path is shorter, say, 11-18. The block that joins the paths again will be block 21, so no matter which path you came from, it's still the highest number.
And as well, you can then program a 'threat' option in the tower targeting, where they pick the creep with the highest 'mysquare', the block the creep has determined itself to be in. This would be the creep closest to the finish.