Tutorial I based this project on: http://www.youtube.com/watch?v=KNXfSOx4eEE
Actual program: https://gist.github.com/52234fc597c5b2aeccef (Update 4/03)
This is designed for iPad, landscape viewing. It could be easily tweaked for iPhones, but as I don't own one, I will leave that to you guys hehe
Comments:
This one took a while for me to figure out.. and it still needs some work. But it does what it was intended to do mainly: it uses an A* algorithm to find its path through debri. It can definitely be tweaked more..
The 'player' is the blue block. Its target is the yellow block. Red blocks are randomly placed on the grid. Blue blocks are 'water' and have a speed penalty, so the program tries to avoid them. The algorithm searches for the shortest route.
Every time you click is another step in the not-so-simple algorithm. The numbers on the top left of each grid are the grid index, the numbers on top right are the manhattan distance to goal, the numbers on bottom left are its parent grid, and numbers on bottom right are movement cost (water is 15, land is 10)
This heuristic search is designed so you avoid searching EVERY last pixel for the shortest route, and instead sometimes guess.