MicropolisEngine/src/position.h File Reference

Go to the source code of this file.

Classes

class  Position

Enumerations

enum  Direction2 {
  DIR2_INVALID, DIR2_NORTH, DIR2_NORTH_EAST, DIR2_EAST,
  DIR2_SOUTH_EAST, DIR2_SOUTH, DIR2_SOUTH_WEST, DIR2_WEST,
  DIR2_NORTH_WEST, DIR2_BEGIN = DIR2_NORTH, DIR2_END = DIR2_NORTH_WEST + 1
}

Functions

static Direction2 increment45 (Direction2 dir, int count=1)
static Direction2 increment90 (Direction2 dir)
static Direction2 rotate45 (Direction2 dir, int count=1)
static Direction2 rotate90 (Direction2 dir)
static Direction2 rotate180 (Direction2 dir)
bool operator< (const Position &pos1, const Position &pos2)


Detailed Description

Position handling.

Definition in file position.h.


Enumeration Type Documentation

enum Direction2

Another direction enumeration class, with 8 possible directions.

Todo:
Eliminate Direction.
Todo:
After eliminating Direction, rename this enum to Direction.
Enumerator:
DIR2_INVALID  Invalid direction.
DIR2_NORTH  Direction pointing north.
DIR2_NORTH_EAST  Direction pointing north-east.
DIR2_EAST  Direction pointing east.
DIR2_SOUTH_EAST  Direction pointing south-east.
DIR2_SOUTH  Direction pointing south.
DIR2_SOUTH_WEST  Direction pointing south-west.
DIR2_WEST  Direction pointing west.
DIR2_NORTH_WEST  Direction pointing north-west.
DIR2_BEGIN  First valid direction.
DIR2_END  End-condition for directions.

Definition at line 72 of file position.h.


Function Documentation

static Direction2 increment45 ( Direction2  dir,
int  count = 1 
) [inline, static]

Increment the direction by 45 degrees.

Parameters:
dir Direction to rotate.
Returns:
Rotated direction, possibly >= DIR2_END.

Definition at line 92 of file position.h.

Referenced by increment90().

static Direction2 increment90 ( Direction2  dir  )  [inline, static]

Increment the direction by 90 degrees.

Parameters:
dir Direction to rotate.
Returns:
Rotated direction, possibly >= DIR2_END.

Definition at line 103 of file position.h.

References increment45().

Referenced by Micropolis::doPowerScan().

bool operator< ( const Position pos1,
const Position pos2 
) [inline]

Less-than comparison on positions (needed for map since Position is used as key value).

Parameters:
pos1 First position.
pos2 Second position.
Returns:
First position is smaller than second position.

Definition at line 176 of file position.h.

References Position::posX, and Position::posY.

static Direction2 rotate180 ( Direction2  dir  )  [inline, static]

Rotate the direction by 180 degrees.

Parameters:
dir Direction to rotate.
Returns:
Rotated direction.

Definition at line 133 of file position.h.

References rotate45().

Referenced by Micropolis::doRivers(), and Micropolis::tryDrive().

static Direction2 rotate45 ( Direction2  dir,
int  count = 1 
) [inline, static]

Increment the direction by 45 degrees.

Parameters:
dir Direction to rotate.
Returns:
Rotated direction.

Definition at line 113 of file position.h.

References DIR2_NORTH.

Referenced by Micropolis::doBRiver(), Micropolis::doSRiver(), rotate180(), and rotate90().

static Direction2 rotate90 ( Direction2  dir  )  [inline, static]

Rotate the direction by 90 degrees.

Parameters:
dir Direction to rotate.
Returns:
Rotated direction.

Definition at line 123 of file position.h.

References rotate45().

Referenced by Micropolis::tryGo().


Generated on Wed Feb 2 09:19:22 2011 for Micropolis by  doxygen 1.5.6