January 2016
Intermediate to advanced
304 pages
6h 17m
English
Before we start working with a level grid, we need to know how it is set up! Our level is described as a 2D array of a custom type Tile, a struct defined in Level.h:
// A struct that defines the data values our tiles need.
struct Tile
{
TILE type; // The type of tile this is.
int columnIndex; // The column index of the tile.
int rowIndex; // The row index of the tile.
sf::Sprite sprite; // The tile sprite.
int H; // Heuristic / movement cost to goal.
int G; // Movement cost. (Total of entire path)
int F; // Estimated cost for full path. (G + H)
Tile* parentNode; // Node to reach this node.
};Don't worry about the final four values at this point; we'll use them later when we get to the section on path finding! For now, we just need to ...
Read now
Unlock full access