Coding the A* pathfinding algorithm

With an understanding of the fundamentals of A*, let's start implementing it in our game. This will allow the enemies to follow our player around the level regardless of its topology.

With a complex algorithm such as this, having a visual representation of what's happening is really helpful. Wherever it's appropriate, we will take a look at a visual representation of what's happening using the following example:

Coding the A* pathfinding algorithm

The Tile datatype

Let's start by taking a quick look at the Tile struct that was defined in Level.h. As we've seen, a node contains quite a few values. In the implementation, it's the level tiles that will ...

Get Procedural Content Generation for C++ Game Development 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.