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 ( )


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.

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

Get the next direction counter-clockwise.

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

Get the next direction clockwise.

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

Get the opposite direction.

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

Get the orthogonal direction counter-clockwise.

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

Get the orthogonal direction clockwise.

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

Get a unit vector from a direction.

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.

A vector representing the direction

Member Data Documentation

const Direction gf::Direction::Center

The center, indicates no direction.

const Direction gf::Direction::East

The east direction.

const Direction gf::Direction::North

The north direction.

const Direction gf::Direction::NorthEast

The north-east direction.

const Direction gf::Direction::NorthWest

The north-west direction.

const Direction gf::Direction::South

The south direction.

const Direction gf::Direction::SouthEast

The south-east direction.

const Direction gf::Direction::SouthWest

The south-west direction.

const Direction gf::Direction::West

The west direction.