Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Public Member Functions | Static Public Member Functions | List of all members
gf::HexagonalCells Class Referencefinal

Hexagonal cells. More...

#include <gf/Cells.h>

Inheritance diagram for gf::HexagonalCells:
Inheritance graph
[legend]

Public Member Functions

 HexagonalCells (Vector2f tileSize, float sideLength, CellAxis axis, CellIndex index)
 Make hexagonal cells of the specified size. More...
 
 HexagonalCells (float radius, CellAxis axis, CellIndex index)
 Make hexagonal cells of the specified size. More...
 
RectF computeBounds (Vector2i layerSize) const noexcept override
 Compute the local bounds of the cells. More...
 
RectI computeVisibleArea (const RectF &local) const noexcept override
 Compute the visible area in terms of coordinates. More...
 
RectF computeCellBounds (Vector2i coords) const noexcept override
 Compute the cell bounds. More...
 
Vector2i computeCoordinates (Vector2f position) const noexcept override
 Compute the coordinates of a cell. More...
 
Polyline computePolyline (Vector2i coords) const override
 Compute the polyline representing a cell. More...
 
std::vector< Vector2icomputeNeighbors (Vector2i coords, Vector2i layerSize, Flags< CellNeighborQuery > flags=gf::None) const override
 Compute the neighbors of a cell. More...
 
- Public Member Functions inherited from gf::Cells
virtual ~Cells ()
 Virtual destructor. More...
 
virtual RectF computeBounds (Vector2i layerSize) const noexcept=0
 Compute the local bounds of the cells. More...
 
virtual RectI computeVisibleArea (const RectF &local) const noexcept=0
 Compute the visible area in terms of coordinates. More...
 
virtual RectF computeCellBounds (Vector2i coords) const noexcept=0
 Compute the cell bounds. More...
 
virtual Vector2i computeCoordinates (Vector2f position) const noexcept=0
 Compute the coordinates of a cell. More...
 
virtual Polyline computePolyline (Vector2i coords) const =0
 Compute the polyline representing a cell. More...
 
virtual std::vector< Vector2icomputeNeighbors (Vector2i coords, Vector2i layerSize, Flags< CellNeighborQuery > flags=gf::None) const =0
 Compute the neighbors of a cell. More...
 

Static Public Member Functions

static Vector2f computeRegularSize (CellAxis axis, float radius)
 Get the size of a regular hexagon. More...
 

Detailed Description

Hexagonal cells.

Constructor & Destructor Documentation

◆ HexagonalCells() [1/2]

gf::HexagonalCells::HexagonalCells ( Vector2f  tileSize,
float  sideLength,
CellAxis  axis,
CellIndex  index 
)
inline

Make hexagonal cells of the specified size.

Parameters
tileSizeThe size of a cell
sideLengthThe length of the side
axisThe cells axis
indexThe cells index

◆ HexagonalCells() [2/2]

gf::HexagonalCells::HexagonalCells ( float  radius,
CellAxis  axis,
CellIndex  index 
)
inline

Make hexagonal cells of the specified size.

Parameters
radiusThe radius of the regular hexagon
axisThe cells axis
indexThe cells index

Member Function Documentation

◆ computeBounds()

RectF gf::HexagonalCells::computeBounds ( Vector2i  layerSize) const
overridevirtualnoexcept

Compute the local bounds of the cells.

Parameters
layerSizeThe size of the layer
Returns
The bounds of the cells

Implements gf::Cells.

◆ computeCellBounds()

RectF gf::HexagonalCells::computeCellBounds ( Vector2i  coords) const
overridevirtualnoexcept

Compute the cell bounds.

Parameters
coordsThe coordinates of the cell
Returns
The rectangular bounding box of the cell

Implements gf::Cells.

◆ computeCoordinates()

Vector2i gf::HexagonalCells::computeCoordinates ( Vector2f  position) const
overridevirtualnoexcept

Compute the coordinates of a cell.

Parameters
positionThe local position
Returns
The coordinates of the cell

Implements gf::Cells.

◆ computeNeighbors()

std::vector< Vector2i > gf::HexagonalCells::computeNeighbors ( Vector2i  coords,
Vector2i  layerSize,
Flags< CellNeighborQuery flags = gf::None 
) const
overridevirtual

Compute the neighbors of a cell.

Parameters
coordsThe coordinates of the cell
layerSizeThe size of the layer
flagsThe parameters of the query
Returns
An array of coordinates of the neighbors

Implements gf::Cells.

◆ computePolyline()

Polyline gf::HexagonalCells::computePolyline ( Vector2i  coords) const
overridevirtual

Compute the polyline representing a cell.

Parameters
coordsThe coordinates of the cell
Returns
A polyline (loop) that represents the cell

Implements gf::Cells.

◆ computeRegularSize()

static Vector2f gf::HexagonalCells::computeRegularSize ( CellAxis  axis,
float  radius 
)
static

Get the size of a regular hexagon.

Parameters
axisThe hexagon axis
radiusRadius of hexagon
Returns
The size of the bounding box of the hexagon

◆ computeVisibleArea()

RectI gf::HexagonalCells::computeVisibleArea ( const RectF local) const
overridevirtualnoexcept

Compute the visible area in terms of coordinates.

Parameters
localThe visible area
Returns
The visible coordinates

Implements gf::Cells.