3

In a two-dimensional world simulation, for example the internal model of a robotics engine, or the representation of a world in a role-playing game, ground space is typically separated into a grid used to position items, similar to a game of chess (pawn to E4). I've seen this done both with grids of squares and with grids of hexagons.

What are the advantages and disadvantages each of using squares versus using hexagons as the basis for such a model?

TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46
  • 1
    I'm voting to close this question as off-topic because it is not really about programing – Spektre Dec 31 '16 at 09:44
  • On top of the answer... it is harder to model 3D surface relief with square grid then with hexagons (especially hills and rounded buildings features like towers etc...) limiting square grids to use of less advanced shapes (workaround is to use more tiles and more cells per the same complex shape then in the hexagon grid) also this might interests you [Improving performance of click detection on a staggered column isometric grid](http://stackoverflow.com/a/35917976/2521214) and [2D Diamond (isometric) map editor](http://stackoverflow.com/a/36454198/2521214) – Spektre Dec 31 '16 at 09:49

1 Answers1

3

Squares are easier to deal with, because they map directly to 2-dimensional arrays. And they're also easier to draw, since the math to map squares to pixels is trivial. However, if you allow diagonal movement then you have the problem that diagonal movement is 1.4 times faster than vertical/horizontal movement.

Hexagons are preferred in most war games because the distance from the center of a hexagon to the center of an adjacent hexagon is the same regardless of direction. Hence the speed of motion is the same along all six natural directions. However, keeping track of your hexagons (and their neighbors) in an array requires more work, and drawing hexagons requires some math skills.

user3386109
  • 34,287
  • 7
  • 49
  • 68