Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::HexagonHelper Class Reference

A helper for computing coordinates in a hexagonal map. More...

#include <gf/Hexagon.h>

Public Member Functions

 HexagonHelper (MapCellAxis axis, MapCellIndex index)
 Constructor. More...
 
Vector2f getHexagonSize (float radius) const noexcept
 Get the hexagon size. More...
 
RectF computeBounds (Vector2i size, float radius) const noexcept
 Get the bounds for hexagon cells. More...
 
Vector2f computeCenter (Vector2i coords, float radius) const
 Compute the center of the hexagon. More...
 
std::vector< Vector2fcomputeCorners (Vector2i coords, float radius) const
 Compute the six corners of the hexagon. More...
 

Detailed Description

A helper for computing coordinates in a hexagonal map.

Constructor & Destructor Documentation

◆ HexagonHelper()

gf::HexagonHelper::HexagonHelper ( MapCellAxis  axis,
MapCellIndex  index 
)
inline

Constructor.

Parameters
axisThe orientation of hexagon cells. X for pointy and Y for flat
indexThe index of data storage. Odd or Even indicate on which col or row is the offset
See also
gf::MapCellAxis and gf::MapCellIndex

Member Function Documentation

◆ computeBounds()

RectF gf::HexagonHelper::computeBounds ( Vector2i  size,
float  radius 
) const
noexcept

Get the bounds for hexagon cells.

Parameters
sizeNumber of cells
radiusRadius of hexagon
Returns
The current hexagon size

◆ computeCenter()

Vector2f gf::HexagonHelper::computeCenter ( Vector2i  coords,
float  radius 
) const

Compute the center of the hexagon.

Parameters
coordsThe size of the hexagon in the map
radiusRadius of hexagon
Returns
The position of the center

◆ computeCorners()

std::vector<Vector2f> gf::HexagonHelper::computeCorners ( Vector2i  coords,
float  radius 
) const

Compute the six corners of the hexagon.

Parameters
coordsThe size of the hexagon in the map
radiusRadius of hexagon
Returns
The position of six corners

◆ getHexagonSize()

Vector2f gf::HexagonHelper::getHexagonSize ( float  radius) const
noexcept

Get the hexagon size.

Parameters
radiusRadius of hexagon
Returns
The current hexagon size