Tuesday 12 June 2012

Directional Map Path Finding with a Hexagon Grid



Creating the Hexagon grid:

   We first need to create the hexagon grid, we start off with a simple data structure that contains pointers to each of its neighbours. We also need an isWall flag to determine if the node is a wall node. We also keep a x and y index of were the node is stored in our 2D array.
class HexMapNode
  int x,y;
  boolean isWall = false;
  HexMapNode *top,*topLeft,*topRight = null;
  HexMapNode *bottom, *bottomLeft,*bottomRight = null;
  HexMapNode *selectedNeighbour = null;
  int nodesUntilGoal = 9999;