Path finding
To resolve this problem, we need to implement a path-finding system that will allow us to easily determine the shortest route between any two squares on the tile map. The path needs to take walls into account, and needs to be fast enough that several enemy tanks can run the check without bogging down the game because in addition to verifying the placement of game objects, the same code will be used to allow enemy robots to move towards the player and attempt to destroy him.
The A* path-finding algorithm
The method we will implement for Robot Rampage is called A* (pronounced "A Star"). This path-finding system is fairly straightforward and relatively fast, as it uses an educated guess system to try out potential paths between two points. ...
Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.