#include "Face.h" Face Face::FACES[6] = { Face(0, 0, 1, 0, "Up"), Face(1, 1, 0, 0, "North"), Face(2, 0, 0, 1, "East"), Face(3, 0, -1, 0, "Down"), Face(4, -1, 0, 0, "South"), Face(5, 0, 0, -1, "West") }; Face& Face::UP = FACES[0]; Face& Face::DOWN = FACES[3]; Face& Face::NORTH = FACES[1]; Face& Face::SOUTH = FACES[4]; Face& Face::EAST = FACES[2]; Face& Face::WEST = FACES[5]; Face::Face(int index, int offsetX, int offsetY, int offsetZ, const char* name) : index(index), offsetX(offsetX), offsetY(offsetY), offsetZ(offsetZ), name(name) { } int Face::getX() const { return offsetX; } int Face::getY() const { return offsetY; } int Face::getZ() const { return offsetZ; } Face& Face::getOpposite() const { return FACES[(index + 3) % 6]; } const char* Face::getName() const { return name; } void Face::forEach(void* data, void (*fun) (Face&, void*)) { for(int i = 0; i < 6; i++) { fun(FACES[i], data); } } bool operator==(const Face& l, const Face& r) { return &l == &r; } bool operator!=(const Face& l, const Face& r) { return &l != &r; } std::ostream& operator<<(std::ostream& os, const Face& f) { os << f.getName(); return os; }