EvenQCoordinates

Data class representing even-Q coordinates in a flat-topped hexagonal grid layout. The Even-Q coordinate system makes use of a 2D grid representation (column and row), which differs from the cube coordinates system used by the HexCoordinates:

  • In the HexCoordinates class, the hexagonal grid coordinates are denoted by three axes q, r, s, hence forming a cube structure.

  • The EvenQCoordinates class, on the other hand, interprets the hexagonal grid using a vertical column system aligned with even-Q. Here, the column ('q') has its origin at the top-left.

  • This layout causes every other column to be offset. Consequently, when progressing vertically in the positive direction, the even-numbered columns are slightly to the left of odd-numbered columns.

The col field denotes the column (equivalent to the q-axis in cube coordinates), while the row denotes the row.

The EvenQCoordinates class can be particularly useful when dealing with UI elements or graphical representations where Cartesian coordinates (column and row) are more intuitive to work with.

Constructors

Link copied to clipboard
constructor(col: Int, row: Int)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val col: Int
Link copied to clipboard
open override val hex: HexCoordinates

Expects a property of HexCoordinates type, which should be provided by instances of this interface.

Link copied to clipboard
open override val q: Int

The column coordinate of the point on the hexagonal grid.

Link copied to clipboard
open override val r: Int

The row coordinate of the point on the hexagonal grid.

Link copied to clipboard
open override val row: Int

Functions

Link copied to clipboard
operator fun get(direction: Int): EvenQCoordinates

Retrieves neighbouring grid element in the particular direction.

Link copied to clipboard
open override fun HexCoordinates.into(): EvenQCoordinates

Transforms the given this from HexCoordinates into the corresponding subtype of Coordinates.

Link copied to clipboard