Simple A* Path Finding on a Tile Grid

Next we are going to take a look at a subject that applies to many games, Path Finding. We are going to revisit the tile-based grid drawing from Chapter 4 and apply JavaScript path finding algorithms to the game screen. This type of logic can be used in many types of games, from the simplest Pac-Man style contests to the most complicated 3D shooters. We are not going to develop our own path finding algorithms in this chapter; instead, we will make use of a pre-existing A-Star (or A* as we will continue to call it over the next few sections) and use the canvas to display the results.

Get HTML5 Canvas, 2nd Edition 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.