本文整理汇总了C++中Piece::GetOccupiedSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ Piece::GetOccupiedSpace方法的具体用法?C++ Piece::GetOccupiedSpace怎么用?C++ Piece::GetOccupiedSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piece
的用法示例。
在下文中一共展示了Piece::GetOccupiedSpace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ValidPieceSpot
bool Board::ValidPieceSpot(Piece loc) {
//get's all current positions on board
//Get all possible occupied space
//Get availability grid
int available[10][10];
bool check = GetAvailabilityGrid(available);
if (check == false) {
//delete available;
return false;
}
vector<Coordinate> ls;
ls = loc.GetOccupiedSpace();
//check if each occupied space is valid
for (int i = 0; i < getPieceLength(loc.Type); i++) {
//if out of bounds instantly false
if (ls[i].x < 0 || ls[i].x > 9 || ls[i].y < 0 || ls[i].y > 9) {
return false;
}
//if spot is already taken, return false
if (available[ls[i].x][ls[i].y] != 0) {
return false;
}
}
return true;
}
示例2: RenderToGrid
void UI::RenderToGrid (WINDOW* wnd, Piece pc, char* l) {
vector<Coordinate> ls = pc.GetOccupiedSpace();
//
for (auto c: ls) {
if (c.x < 0 || c.x > 9 || c.y < 0 || c.y > 9) {
break;
}
else {
mvwprintw(wnd, (c.x * 2) + 3, (c.y * 2) + 4, l);
}
}
}
示例3:
Piece *Board::GetPieceAtCoordinate(Coordinate c) {
if (c.x < 0 || c.x > 9 || c.y < 0 || c.y > 9) {
return NULL;
}
vector<Coordinate> ls;
//Get's all pieces
//for (auto pc : BoardPieces) {
for (uint8_t i = 0; i < BoardPieces.size(); i++){
Piece pc = BoardPieces.at(i);
ls = pc.GetOccupiedSpace();
for (int i = 0; i < getPieceLength(pc.Type); i++) {
if (ls[i].x == c.x && ls[i].y == c.y) {
return &BoardPieces[i];
}
}
}
return NULL;
}