Gamedev Framework (gf)  0.1.0
A C++11 framework for 2D games
Public Member Functions | Static Public Attributes | List of all members
gf::Direction Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

gf::Direction::Direction ( )
inline

Constructor.

By default, no direction, i.e. center (see gf::Direction::Center)

Member Function Documentation

float gf::Direction::getAngle ( ) const

Get an angle from a direction.

North is at angle 0 and angle grows clockwise.

Returns
an angle (in radians) representing the direction
Direction gf::Direction::getNextDirectionCCW ( ) const

Get the next direction counter-clockwise.

Returns
The next direction counter-clockwise
Direction gf::Direction::getNextDirectionCW ( ) const

Get the next direction clockwise.

Returns
The next direction clockwise
Direction gf::Direction::getOppositeDirection ( ) const

Get the opposite direction.

Returns
The opposite direction
Direction gf::Direction::getOrthogonalDirectionCCW ( ) const

Get the orthogonal direction counter-clockwise.

Returns
The orthogonal direction counter-clockwise
Direction gf::Direction::getOrthogonalDirectionCW ( ) const

Get the orthogonal direction clockwise.

Returns
The orthogonal direction clockwise
Vector2f gf::Direction::getUnit ( ) const

Get a unit vector from a direction.

Returns
A unit vector representing the 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.

Returns
A vector representing the direction

Member Data Documentation

const Direction gf::Direction::Center
static

The center, indicates no direction.

const Direction gf::Direction::East
static

The east direction.

const Direction gf::Direction::North
static

The north direction.

const Direction gf::Direction::NorthEast
static

The north-east direction.

const Direction gf::Direction::NorthWest
static

The north-west direction.

const Direction gf::Direction::South
static

The south direction.

const Direction gf::Direction::SouthEast
static

The south-east direction.

const Direction gf::Direction::SouthWest
static

The south-west direction.

const Direction gf::Direction::West
static

The west direction.