Skip to content

Implementation: Hexagonal tiles

mhwombat edited this page Sep 6, 2012 · 1 revision

For hexagonal tiles, it is convenient to define a third component z, where

z = -x - y

Then the minimum number of moves to go from tile (x1,y1) to tile (x2,y2) is given by

maximum (|x2-x1|, |y2-y1|, |z2-z1|)

And the tiles adjacent to a tile at (x,y) are

[(x-1,y), (x-1,y+1), (x,y+1), (x+1,y), (x+1,y-1), (x,y-1)]

The indexing scheme is illustrated below. A line of tiles on a diagonal like / will have the same value for x. A horizontal line of tiles will have the same value for y.

Hexagonal grid with hexagonal tiles

Parallelogram-shaped grid with hexagonal tiles

Clone this wiki locally