   battle field rappresentation
  Hy.I would create a battle field rappresentation based on hexagon or quad , for a rts game.How i design the quad or exagon in the battlefield?Then i would have functions like:Cell  cell= inWhatCellTheCharacterIs();character = whatCharacterIsInCell(Cell);Cell[] cells = whatCellAreInfluencedByTheBomb?  ecc...and a path finder for the battle field.I'm a c++ programmer but I know nothing on this implemetation, how do it?There is some documentation or links?Thanks   
  Use std::vector<>.   ;  can you help me more?   ;  I'd suggest some scheme that allows you to quickly find a cell in a grid, i.e. for quads you'd address a cell by something like y * width + x and look up that cell in a vector or array. Neighboring cells could be adressed by adding +/- 1 to x and/or y.For hexagons the addressing would be a bit different, since a cell would have at max 6 neighboring cells (typically 2 in the same and row 2 in each of the neighboring rows). The addressing depends on the shape of the grid but if each row has the same number of cells it should be fairly easy.Assume the following layout: x x x xx 9 x x x 5 x xx x x xThe neighboring cells of cell 5 (lower left cell is 0) could be retreived by:left: y * width + x - 1right: y * width + x + 1top left: (y + 1) * width + xtop right: (y + 1) * width + x + 1bottom left: (y - 1) * width + xbottom right: (y - 1) * width + x + 1For cell 9 you would use  + x for the the top right and bottom right cells and + (x - 1) for the top left and bottom left cells.   ;  Moved to For Beginners.   ;Quote:Original post by Lord_EvilI'd suggest some scheme that allows you to quickly find a cell in a grid, i.e. for quads you'd address a cell by something like y * width + x and look up that cell in a vector or array. Neighboring cells could be adressed by adding +/- 1 to x and/or y.For hexagons the addressing would be a bit different, since a cell would have at max 6 neighboring cells (typically 2 in the same and row 2 in each of the neighboring rows). The addressing depends on the shape of the grid but if each row has the same number of cells it should be fairly easy.Assume the following layout: x x x xx 9 x x x 5 x xx x x xThe neighboring cells of cell 5 (lower left cell is 0) could be retreived by:left: y * width + x - 1right: y * width + x + 1top left: (y + 1) * width + xtop right: (y + 1) * width + x + 1bottom left: (y - 1) * width + xbottom right: (y - 1) * width + x + 1For cell 9 you would use  + x for the the top right and bottom right cells and + (x - 1) for the top left and bottom left cells.Thanks. very fine.But there are positive aspect in exagon respect the quads?How?THanks.