Expand description

While most hex-grid-based 2D games use multiple coordinates, hex-spiral uses a single-coordinate spiral, where the central hex has the position 0, and further hexes are placed within theoretical hexagonal rings that surround it. The hexes are flat-topped and every ring is indexed starting with the hex on the top edge of the previous ring and with further positions growing clockwise.

Structs

An iterator returning subsequent neighboring positions in the given direction. The top direction is 0, and it increases up to 5 clockwise.

Functions

Returns true if the given 2 positions are neighbors.

Returns true if the given position is at one of the tips of a ring.

Returns true if the given list of positions consists of subsequent neighbors.

Returns the 6 neighbors of the given position, always in the same clockwise order.

The index of the ring for the given position.

Returns the index of the edge of the ring the given position belongs to.

The starting position of hexes within the ring with the given index.

Type Definitions