4
\$\begingroup\$

I am planning to implement in my game a very big map. I won't be showing all map at once but rather only a selected part of it. Additionally, I would need to connect hexes into bigger pieces (provinces) and show them altogether.

I was thinking of using a hex map. Can you recommend any manual relating to working on coordinates on hex map? I am looking for a good way to store the hex positions on map so that I can easily find nearby hexes and do not have to load all the map at once.

Maybe you may also recommend some reliable alternatives to hex maps?

I am limited to 2D.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ I've written a little bit about hex coordinates here. \$\endgroup\$
    – amitp
    Jun 6, 2015 at 12:30
  • \$\begingroup\$ A little while ago someone asked a question about a hex tile addressing scheme called a "Spiral Honeycomb Mosaic" - it has a neat fractal structure you might find interesting, using base-7 numbering to index hexagonal clusters of hex cells. It's a bit trickier to think about than the schemes recommended in answers below though. gamedev.stackexchange.com/questions/71785/… \$\endgroup\$
    – DMGregory
    Jun 8, 2015 at 13:44

2 Answers 2

1
\$\begingroup\$

If you are interested in doing a hex map you should definitely check out this http://www.redblobgames.com/grids/hexagons/

It coves few different methods of storing hex grids as well as basic operations like distance, fov, rotation and many more. It also describes how to do mapping from screen coordinates to hex coordinates and vice versa.

\$\endgroup\$
5
\$\begingroup\$

All three uniform 2D grids can be stored in a rectangular grid, you just have to scale and shear it to fit the one you're aiming for.

Rectangular and hexagonal grid relation

To know what regions you need to load just transform the viewport extents to the data's coordinate system.

\$\endgroup\$
2
  • \$\begingroup\$ How can I store hex grid in a rectangular grid? Can you provide any reference? \$\endgroup\$
    – Abdel5
    Jun 6, 2015 at 11:59
  • 1
    \$\begingroup\$ @Abdel5 added an image, does it help? \$\endgroup\$ Jun 6, 2015 at 12:06

Not the answer you're looking for? Browse other questions tagged .