hextille v0.1.0 Hextille.HexGrid View Source
Module for creating HexGrids
Link to this section Summary
Functions
Finds the columns and rows representing boundaries of a MapSet
Returns a MapSet containing grid of row
rows and col
columns of
hexagon tiles in Cube coordinates.
Top left corner of the grid is at %Cube{q: 0, r: 0, s: 0}, unless offset is shifted
Checks if hexagon has any neighbours in MapSet
Checks if hexagon has any neighbour in direction at MapSet
Link to this section Functions
Finds the columns and rows representing boundaries of a MapSet.
iex> a = HexGrid.create(4, 4, -2, -2) iex> b = HexGrid.create(4, 4, -3, -5) iex> HexGrid.boundaries(a) %{max_col: 2, max_row: 2, min_col: -2, min_row: -2} iex> HexGrid.boundaries(b) %{max_col: 1, max_row: -1, min_col: -3, min_row: -5}
Returns a MapSet containing grid of row
rows and col
columns of
hexagon tiles in Cube coordinates.
Top left corner of the grid is at %Cube{q: 0, r: 0, s: 0}, unless offset is shifted.
Checks if hexagon has any neighbours in MapSet
iex> h = HexGrid.create(4, 4, -2, -2) iex> HexGrid.has_neighbour(h, %Cube{q: 1, r: -2, s: 1}) %{east: true, north_east: false, north_west: false, south_east: true, south_west: true, west: true}
Checks if hexagon has any neighbour in direction at MapSet
iex> h = HexGrid.create(4, 4, -2, -2) iex> HexGrid.has_neighbour(h, %Cube{q: 1, r: -2, s: 1}, :east) true iex> HexGrid.has_neighbour(h, %Cube{q: 1, r: -2, s: 1}, :north_east) false