Position Class Reference

#include <position.h>

List of all members.

Public Member Functions

 Position ()
 Position (int x, int y)
 Position (const Position &pos)
 Position (const Position &pos, Direction2 dir)
 Position (const Position &pos, int dx, int dy)
Positionoperator= (const Position &pos)
bool move (Direction2 dir)
bool testBounds ()

Public Attributes

int posX
 Horizontal coordinate of the position.
int posY
 Vertical coordnate of the position.


Detailed Description

X/Y position.

Definition at line 140 of file position.h.


Constructor & Destructor Documentation

Position::Position (  ) 

Default constructor.

Definition at line 74 of file position.cpp.

References posX, and posY.

Position::Position ( int  x,
int  y 
)

Construct a position at a given x and y coordinate.

Parameters:
x X coordinate of the new position.
y Y coordinate of the new position.

Definition at line 85 of file position.cpp.

References posX, and posY.

Position::Position ( const Position pos  ) 

Copy constructor.

Parameters:
pos Position to copy.

Definition at line 95 of file position.cpp.

References posX, and posY.

Position::Position ( const Position pos,
Direction2  dir 
)

Copy constructor with a single tile movement.

Parameters:
pos Position to copy.
dir Direction to move into.

Definition at line 106 of file position.cpp.

References move(), posX, and posY.

Position::Position ( const Position pos,
int  dx,
int  dy 
)

Copy sonstructor with arbitrary movement.

Parameters:
pos Position to copy.
dx Horizontal offset.
dy Vertical offset.

Definition at line 119 of file position.cpp.

References posX, and posY.


Member Function Documentation

Position & Position::operator= ( const Position pos  ) 

Assignment operator.

Parameters:
pos Position to copy.

Definition at line 129 of file position.cpp.

References posX, and posY.

bool Position::move ( Direction2  dir  ) 

Move the position one step in the indicated direction.

Parameters:
dir Direction to move into.
Returns:
Position moved in the indicated direction.

Definition at line 144 of file position.cpp.

References DIR2_EAST, DIR2_INVALID, DIR2_NORTH, DIR2_NORTH_EAST, DIR2_NORTH_WEST, DIR2_SOUTH, DIR2_SOUTH_EAST, DIR2_SOUTH_WEST, DIR2_WEST, NOT_REACHED, posX, posY, WORLD_H, and WORLD_W.

Referenced by Micropolis::doBRiver(), Micropolis::doPowerScan(), Micropolis::doSRiver(), Position(), Micropolis::testForConductive(), Micropolis::treeSplash(), and Micropolis::tryDrive().

bool Position::testBounds (  )  [inline]

Test whether the position is on-map.

Returns:
Position is on-map.

Definition at line 163 of file position.h.

References posX, posY, WORLD_H, and WORLD_W.

Referenced by Micropolis::addToTrafficDensityMap(), and Micropolis::treeSplash().


The documentation for this class was generated from the following files:

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