#include <hex.h>
Definition at line 260 of file hex.h.
Public Member Functions | |
const Grid & | grid (void) const |
const Edge * | edge (const Direction &d) const |
Edge * | edge (const Direction &d) |
Hex * | go (const Direction &d, int distance=1) const |
Hex * | go (const std::string &steps) const |
Point | centre (void) const |
std::string | str (void) const |
Hex (const Grid &grid, int i_, int j_) | |
Static Public Member Functions | |
static int | _key (int i, int j) |
Generates a unique key for co-ordinates i,j. | |
Public Attributes | |
const int | i |
in units of I | |
const int | j |
in units of J | |
Friends | |
class | Grid |
hex::Hex::Hex | ( | const Grid & | grid, | |
int | i_, | |||
int | j_ | |||
) |
const Grid& hex::Hex::grid | ( | void | ) | const [inline] |
Definition at line 47 of file hex.cc.
Referenced by hex::Area::boundary(), hex::Edge::complement(), hex::move::Topography::increase_hex_cost(), hex::Edge::next_in(), hex::Edge::next_out(), hex::move::Topography::override_hex_cost(), and hex::move::Topography::step().
00048 { 00049 return const_cast<Edge*>( const_cast<Hex*>(this)->edge( d ) ); 00050 }
Definition at line 32 of file hex.cc.
References hex::A, hex::B, hex::C, hex::D, and hex::E.
00033 { 00034 switch(d) 00035 { 00036 case A: return &_edgeA; 00037 case B: return &_edgeB; 00038 case C: return &_edgeC; 00039 case D: return &_edgeD; 00040 case E: return &_edgeE; 00041 default: return &_edgeF; 00042 } 00043 }
Definition at line 54 of file hex.cc.
References hex::go(), hex::Grid::hex(), i, and j.
Referenced by hex::Grid::area(), hex::Edge::complement(), hex::Area::fillpaths(), and hex::move::Topography::step().
00055 { 00056 int i_ =this->i; 00057 int j_ =this->j; 00058 hex::go(i_,j_,d,distance); // in/out: i_,j_ 00059 try 00060 { 00061 return _grid.hex(i_,j_); 00062 } 00063 catch(hex::out_of_range) 00064 { 00065 return NULL; 00066 } 00067 }
Hex * hex::Hex::go | ( | const std::string & | steps | ) | const |
Definition at line 71 of file hex.cc.
References hex::go(), hex::Grid::hex(), i, and j.
00072 { 00073 int i_ =this->i; 00074 int j_ =this->j; 00075 hex::go(i_,j_,steps); // in/out: i_,j_ 00076 try 00077 { 00078 return _grid.hex(i_,j_); 00079 } 00080 catch(hex::out_of_range) 00081 { 00082 return NULL; 00083 } 00084 }
Point hex::Hex::centre | ( | void | ) | const |
Definition at line 88 of file hex.cc.
References i, hex::I, j, hex::J, hex::K, hex::Point::x, and hex::Point::y.
Referenced by hex::move::_Route::distance(), hex::Edge::join_point(), and hex::Edge::start_point().
00089 { 00090 Point result; 00091 if(this->j % 2) 00092 result.x = I * (1 + this->i); // odd rows 00093 else 00094 result.x = I/2.0 + I * this->i; // even rows 00095 result.y = K + J * this->j; 00096 return result; 00097 }
std::string hex::Hex::str | ( | void | ) | const |
static int hex::Hex::_key | ( | int | i, | |
int | j | |||
) | [inline, static] |
Generates a unique key for co-ordinates i,j.
(i,j < 2^14)
Definition at line 275 of file hex.h.
Referenced by hex::Grid::hex().
const int hex::Hex::i |
in units of I
Definition at line 265 of file hex.h.
Referenced by hex::Area::boundary(), centre(), go(), hex::range(), hex::steps(), and str().
const int hex::Hex::j |
in units of J
Definition at line 266 of file hex.h.
Referenced by hex::Area::boundary(), centre(), go(), hex::range(), hex::steps(), and str().