Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It would represent a map that is semi-square of arbitrary size. It would have a simple system for representation of the map coordinates such as 0101 (first column, 1st hex). I'd want the map to be able to tell me the distance between two points, and what other hexes lay between those two points as a list or array.

I don't care as much about the language but c# or python would be ideal.

Does one exist?

share|improve this question

closed as off-topic by Sean Middleditch, bummzack, Byte56 Aug 26 '13 at 14:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions that are about "which tech to use" are outside the scope of the site. For more information, see this meta post" – Sean Middleditch, bummzack, Byte56
If this question can be reworded to fit the rules in the help center, please edit the question.

This might help, Mappy. – iamcreasy Dec 24 '11 at 6:23
Look at this: – Abdel5 Oct 4 '15 at 17:58
That is bloody excellent @abdel5, thanks for sharing that! – Pete Mancini Oct 13 '15 at 21:35
up vote 4 down vote accepted

Not a library but more of a tutorial. Looking though the tutorial it seems to do everything you requested. It uses C# / XNA.

Edit: Link is dead so see the WaybackMachine

share|improve this answer
Do you have one for pygame? =) – Kenneth Posey Dec 24 '11 at 8:11
No. But the math is the same. Incidentally, the version of that code in includes a variety with the other alignment. [Seeing my own article pop up as an answer is nice.] – Blecki Dec 24 '11 at 13:11
Sorry it took so long to mark this as the answer. It really is a fantastic link. – Pete Mancini Aug 8 '12 at 22:49
Sadly, the link is dead. Page is just a bunch of ads now. – luiscubal Sep 27 '12 at 21:05
FYI, for those who haven't heard of it - the Wayback Machine tries to archive old pages. In this case, it has one snapshot of the tutorial (but not the images, alas), so there's at least code and text to read. – Cyclops Sep 28 '12 at 11:30

The Cocos 2D library has support for rendering hex tile maps. I have not used it, but the library has been around for years and seems quite popular.

That might be more for rendering than for doing calculations on the hex map though. Fortunately what you ask for is quite simple to implement anyway, especially if you use a good x/y coordinate system for your hexes. See:

share|improve this answer

I believe the Java version of the Tiled Map Editor supports hexagonal maps. Have a look for yourself at:

share|improve this answer
It used to do that, but you had to uncomment some lines in the code to be able to creat hexagonal maps. Also it had some bugs that I am not sure if they were solved or if you would still have to apply some manual patch from the Tiled mailing list (I remember because I posted one patch). Unfortunately having a tile editor will not solve the original problem of handling the coordinates in the game. – pelle Apr 30 '14 at 10:46
There are also hexmap-enabled forks of the more recent C++ version of Tiled. – pelle Apr 30 '14 at 10:47

Pieter Geerkens (who is here on stackexchange) has a C# library for hexagons.

share|improve this answer
Thank you for the plug; I try to extend or enhance the library at least once a month. – Pieter Geerkens Aug 28 '13 at 4:08

Not the answer you're looking for? Browse other questions tagged or ask your own question.