Gamedev Framework (gf)
0.1.0
A C++11 framework for 2D games
|
Cardinal and ordinal directions. More...
#include <gf/Direction.h>
Public Member Functions | |
Direction () | |
Constructor. More... | |
Vector2f | getUnit () const |
Get a unit vector from a direction. More... | |
Vector2i | getVector () const |
Get a vector from a direction. More... | |
float | getAngle () const |
Get an angle from a direction. More... | |
Direction | getOppositeDirection () const |
Get the opposite direction. More... | |
Direction | getOrthogonalDirectionCW () const |
Get the orthogonal direction clockwise. More... | |
Direction | getOrthogonalDirectionCCW () const |
Get the orthogonal direction counter-clockwise. More... | |
Direction | getNextDirectionCW () const |
Get the next direction clockwise. More... | |
Direction | getNextDirectionCCW () const |
Get the next direction counter-clockwise. More... | |
Static Public Attributes | |
static const Direction | Center |
The center, indicates no direction. More... | |
static const Direction | North |
The north direction. More... | |
static const Direction | NorthEast |
The north-east direction. More... | |
static const Direction | East |
The east direction. More... | |
static const Direction | SouthEast |
The south-east direction. More... | |
static const Direction | South |
The south direction. More... | |
static const Direction | SouthWest |
The south-west direction. More... | |
static const Direction | West |
The west direction. More... | |
static const Direction | NorthWest |
The north-west direction. More... | |
Cardinal and ordinal directions.
gf::Direction represents one the four cardinal directions and the four ordinal (or intercardinal) directions. A special value is added to represent the center, it indicates no direction.
|
inline |
Constructor.
By default, no direction, i.e. center (see gf::Direction::Center)
float gf::Direction::getAngle | ( | ) | const |
Get an angle from a direction.
North is at angle 0 and angle grows clockwise.
Direction gf::Direction::getNextDirectionCCW | ( | ) | const |
Get the next direction counter-clockwise.
Direction gf::Direction::getNextDirectionCW | ( | ) | const |
Get the next direction clockwise.
Direction gf::Direction::getOppositeDirection | ( | ) | const |
Get the opposite direction.
Direction gf::Direction::getOrthogonalDirectionCCW | ( | ) | const |
Get the orthogonal direction counter-clockwise.
Direction gf::Direction::getOrthogonalDirectionCW | ( | ) | const |
Get the orthogonal direction clockwise.
Vector2f gf::Direction::getUnit | ( | ) | const |
Get a unit vector from a direction.
Vector2i gf::Direction::getVector | ( | ) | const |
Get a vector from a direction.
The vector has its coordinates at -1, 0 or 1 depending on the direction. It can be used to represent the displacement on a grid in the given direction.
|
static |
The center, indicates no direction.
|
static |
The east direction.
|
static |
The north direction.
|
static |
The north-east direction.
|
static |
The north-west direction.
|
static |
The south direction.
|
static |
The south-east direction.
|
static |
The south-west direction.
|
static |
The west direction.