3

I have an idea for a game map and have researched some into it. What i'm going to do is have a 2D map(s) that a GM can pick from, or they can create their own using predefined images or images of a particular size they can upload.

From what i've seen, people are using a 2-Dimensional Array, but this is for tiles.

So what my question would be, is there a better way of doing this, for Hexagon? Not necessarily easier, but better. Something that can be used on a large scale, say 1000x1000 hex (100x100 px, 50 radius)

Edit: I found this site that explains a way to draw out the hexagons. I think i might follow it, unless someone knows a better way.

  • 1
    Define "better". By the way, this sort of question is probably a better fit for the Game Development Stack Exchange. It's not off-topic here, but you're more likely to find someone who's solved these problems over there. – Doval Aug 03 '14 at 22:42
  • @Doval I guess a more practical way than setting up a 2-D array. Thanks, I'll check it out. Didn't know there was a game Dev SE. – CodeMonkey Aug 03 '14 at 23:56

1 Answers1

7

You can totally use a 2-D array for a hexagonal map. Red Blob Games has a colossal list of hexagonal resources as well as a massively in-depth tutorial including how to map hexagons to a square grid for storage.

Now that you can map hexagons to a 2-D array, I'll let you in on a secret, it doesn't technically matter which you use since there's potentially a better way to store these.

This is a Quad Tree:

From Wikipedia.org: Quad Tree Image

Quad Trees are commonly used to index spatial data and being that they are trees, the can be much more compact than arrays. They also are more flexible as they don't have to be stored sequentially. However, this will only be useful if you are storing maps that are very very large, so you might want to combine the two approaches depending on your allowed map sizes and other implementation related factors.

  • Haven't heard of Quad Trees. Sounds like it might be easier to keep track of the placement of each hex. Thanks. I'll check it out. – CodeMonkey Aug 04 '14 at 00:50