C# Hex-Grid utilities for Board-Game Development
A tool-kit of utilities for building board- and strategy-games on a hexagonal grid, providing these features:
- Use of Canonical coordinates (ICoordsCanon interface) for many game calculations makes them clear to understand, and often obviously correct.
- Storage of board definition optimized by use of Rectangular coordinates (ICoordsUser interface) as array indices.
- Automatic (all-integer for efficiency in nested loops) conversion between Canonical, Recangular (from upper-left), and Custom coordinates (ICoordsCustom interface) available by implementing them all in a single struct
with caching and lazy evaluation.
- Hex-picking (identifying the hex selected by the user).
- Path-finding against a step-cost function on entry hex and entry hexside.
- Field-of-View determination against elevated terrain
- Mouse-wheel zoom and scroll
- Faster path-finding at long range (but loses agent orientation)
- Map transposition
Got questions? Please leave a comment
(or start a discussion
thread) and I will get back to you as quickly as I can.Feb. 23, 2013 - V 2.0:
Feb. 24, 2013 - V3.0:
- Abstracted MapBoard and MapDisplay functionality into separate classes;
- Corrected PathFinder to use -1 as Impassable flag instead of 999;
- Added demonstration of simple map transposition to HexGridExample; and
- Code clean-up for better exposition of principles.
Apr 28, 2013 - V4.0 (Breaking Change - see release notes):
- Finally fixed that horrible ficker on Resize and Scroll;
- Added TerrainMap example;
- Added demonstration of Shadow-Casting Field-of-View on both maps; and
- Removed reference web pages out of source download to make it a more reasonable size.
- Faster path-finding at longer ranges (controllable range cut-over);
- Mouse-wheel zoom;
- Mouse-wheel scroll;
- Map transposition;
- Improved code readability; and
- Other minor enhancements that I lost track of
Reviews and Ratings
If you downloaded this library and found it useful (and even if you didn't actually; I can take brickbats as well as bouquets), please select Review This Release
on the Downloads page. You will be presented with a dialog box where you can review and rate the release. Specific issues can also be reported on the Issues
I appreciate all feedback, and promise to read all comments and issues.
Many thanks to Eric Lippert for inspiring the path-finding and field-of-view implementation, by providing the original algorithms on a rectangular grid.