Level tiles
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 know that each tile
struct stores its type, position in the 2D array, and its sprite. All the possible tile
types are defined in an enumerator in Util.h
, as follows:
// All possible...