Physicist Leon

physicist and programmer

Hexagonal Grids. Hexagonal grids are used in some games but aren’t quite as straightforward or common as square grids.

I’ve been collecting hex grid resources for nearly 20 years, and wrote this guide to the most elegant approaches that lead to the simplest code, largely based on the guides by Charles Fu and Clark Verbrugge. I’ll describe the various ways to make hex grids (I’ve counted 74 so far!) , the relationships between them, as well as some common algorithms. Many parts of this page are interactive; choosing a type of grid will update diagrams, code, and text to match. The code samples on this page are written in pseudo-code; they’re meant to be easy to read and understand so that you can write your own implementation. This page includes interactive diagrams that require your browser to have SVG and Javascript enabled. Basics Switch to or back to hexagons. Hexagons are 6-sided polygons. Angles In a regular hexagon the interior angles are 120°. Add(center, polar(size, 2 * PI / 6 * (i + 0.5)) Try: and: .