Skip to content
mhwombat edited this page Jun 27, 2013 · 1 revision

Grids based on hexagonal tiles are useful because tiles can have six neighbours, corresponding to six directions of movement in a game. UnboundedHexGrid is an infinite, unbounded, grid filled with hexagonal tiles. 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. The equations used are presented in Implementation: Hexagonal tiles.

Unbounded grid with hexagonal tiles

hexHexGrid s returns a grid of hexagonal shape, with sides of length s, using hexagonal tiles. The centre of the grid always consists of a single tile.

Hexagonal grid with hexagonal tiles

paraHexGrid r c returns a grid in the shape of a parallelogram with r rows and c columns, using hexagonal tiles. 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. Depending on whether the number of rows and columns is even or odd, the centre of the grid may consist of one, two, or four tiles.

Parallelogram-shaped grid with hexagonal tiles

Clone this wiki locally