stmm-games-doc  0.32.0
Public Types | Static Public Member Functions | List of all members
stmg::Direction Class Reference

Public Types

enum  VALUE { UP = 1, DOWN = 2, LEFT = 0, RIGHT = 3 }
 The possible direction values. More...
 

Static Public Member Functions

static VALUE fromDelta (int32_t nDx, int32_t nDy) noexcept
 The direction from the unary delta of the coords. More...
 
static int32_t deltaX (VALUE eDir) noexcept
 The x delta of a given direction. More...
 
static int32_t deltaY (VALUE eDir) noexcept
 The y delta of a given direction. More...
 
static VALUE rotateCW (VALUE eDir) noexcept
 The clockwise rotated direction. More...
 
static VALUE rotateCCW (VALUE eDir) noexcept
 The counter clockwise rotated direction. More...
 
static VALUE opposite (VALUE eDir) noexcept
 The opposite direction. More...
 

Member Enumeration Documentation

◆ VALUE

The possible direction values.

Enumerator
UP 

Up (dX=0 dY=-1).

DOWN 

Down (dX=0 dY=+1).

LEFT 

Left (dX=-1 dY=0).

RIGHT 

Right (dX=+1 dY=0).

Member Function Documentation

◆ deltaX()

static int32_t stmg::Direction::deltaX ( VALUE  eDir)
inlinestaticnoexcept

The x delta of a given direction.

Parameters
eDirThe direction.
Returns
The x delta.

◆ deltaY()

static int32_t stmg::Direction::deltaY ( VALUE  eDir)
inlinestaticnoexcept

The y delta of a given direction.

Parameters
eDirThe direction.
Returns
The y delta.

◆ fromDelta()

static VALUE stmg::Direction::fromDelta ( int32_t  nDx,
int32_t  nDy 
)
inlinestaticnoexcept

The direction from the unary delta of the coords.

Parameters
nDxThe x delta. Must be either -1, 0 or +1.
nDyThe y delta. Must be either -1, 0 or +1.
Returns
The direction or undefined if abs(nDx + nDy) not 1.

◆ opposite()

static VALUE stmg::Direction::opposite ( VALUE  eDir)
inlinestaticnoexcept

The opposite direction.

Example: The opposite direction of Direction::DOWN is Direction::UP.

Parameters
eDirThe direction.
Returns
The new direction.

◆ rotateCCW()

static VALUE stmg::Direction::rotateCCW ( VALUE  eDir)
inlinestaticnoexcept

The counter clockwise rotated direction.

Example: The counter clockwise rotation of Direction::LEFT is Direction::DOWN.

Parameters
eDirThe direction.
Returns
The new direction.

◆ rotateCW()

static VALUE stmg::Direction::rotateCW ( VALUE  eDir)
inlinestaticnoexcept

The clockwise rotated direction.

Example: The clockwise rotation of Direction::UP is Direction::RIGHT.

Parameters
eDirThe direction.
Returns
The new direction.