Lately, I've been working on a 2-D, hex-based strategy game, in the vein of the old classic, Civil War Generals 2 . Hex grids are a staple of wargames, like the old 5 Star SSI games (Panzer General and all of its descendants), although they've also turned up in some newer games, like Civilization 5 and Battle for Wesnoth.
Although they've been around forever, resources on coding hexmaps are somewhat scanty, in comparison to other things you might want to do with hobby game dev. A list of some canonical articles:
- Isometric 'n; Hexagonal Maps Part 1
- Putting People, Creatures, Items, etc on Iso/Hex Maps, and still having it come out correctly
- Amit's Game Programming Information
Naturally, a lot of the same algorithms you'd use with square grids are equally valid on hex grids. However, often times, those algorithms require some tweaking to work correctly with a hexagonal grid, and its not always easy to understand how they need to be tweaked without a good deal of iteration.
One thing that I found particularly difficult was understanding the correct way to compute distances in a hex grid. Amit's site has some valuable information, but, as much of it is really old, featuring archived newsgroup posts with ascii art and code written in nearly defunct languages, or worse, links that no longer exist, it is really more difficult to understand than it need be.
I'll start with a brief overview of hexagonal grids, and their typical representation.
Below, you'll see a hexagonal grid.