本文整理汇总了C++中Tile::amIDeadNow方法的典型用法代码示例。如果您正苦于以下问题:C++ Tile::amIDeadNow方法的具体用法?C++ Tile::amIDeadNow怎么用?C++ Tile::amIDeadNow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tile
的用法示例。
在下文中一共展示了Tile::amIDeadNow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flagon
/**
* Toggle flag on for a tile. Used to mark that the player believes the tile
* contains a bomb.
*/
bool Game::flagon(CoordinateSet pos) {
Tile *tile = this->getTile(pos);
bool alreadyflag = FLAG_ON(tile->getFlag());
tile->setFlag(true);
if (!tile->amIDeadNow()) {
std::cout << "Whoops, setting flag on a safe tile" << std::endl;
}
if (!alreadyflag) ++this->flagcount;
drawtile(pos);
return !alreadyflag;
}
示例2: press
/**
* Called by amIDeadNow: Press a tile. If !norecursivespread and the tile is
* not a bomb and doesn't have any bomb neighbours, press all tiles in its
* neighbourhood.
*/
void Game::press(CoordinateSet pos, bool norecursivespread) {
Tile *tile = this->getTile(pos);
tile->press();
++this->pressedcount;
drawtile(pos);
if (!tile->amIDeadNow() && (tile->getSurroundings() == 0)) {
CoordinateSetList neighbours = this->neighbourhoodpositions(pos);
CoordinateSetListIt i;
for (i = neighbours.begin(); i != neighbours.end(); ++i) {
if (norecursivespread && this->getTile(*i)->getSurroundings() == 0) continue;
this->amIDeadNow(*i);
}
}
}
示例3: amIDeadNow
/**
* Press a tile. Returns true if the pressed tile was a bomb. Oops!
*/
bool Game::amIDeadNow(CoordinateSet pos) {
Tile *tile = this->getTile(pos);
if (tile == NULL) return false;
if (tile->getDepressed()) return false;
this->press(pos);
if (this->pressedcount == this->tiles.size()-this->minecount) {
this->state = GAMESTATE_WIN;
}
if (tile->amIDeadNow()) {
this->state = GAMESTATE_LOSE;
return true;
}
return false;
}
示例4: findblanks
void Game::findblanks(Dimension dim, CoordinateSet basis, CoordinateSetSet *result) {
if (dim >= this->dimensioncount) {
Tile *tile = this->getTile(basis);
if (tile->getSurroundings() == 0 && !tile->amIDeadNow()) {
result->insert(basis);
}
return;
}
for (unsigned int x = 0; x < this->dimensions[dim]; ++x) {
CoordinateSet temp = basis;
temp[dim] = x;
findblanks(dim+1, temp, result);
}
}
示例5: pressborders
void Game::pressborders() {
CoordinateSetList::const_iterator i;
for (i = coordbegin(); i != coordend(); ++i) {
CoordinateSet c = *i;
CoordinateSetIt x;
SizeVectorIt s;
bool isborder = false;
for (x = c.begin(), s = dimensions.begin(); x != c.end() && s != dimensions.end(); ++x, ++s) {
if (*x == 0 || *x+1 == *s) {
isborder = true;
break;
}
}
if (isborder) {
Tile *tile = getTile(c);
if (!tile->amIDeadNow())
amIDeadNow(c);
}
}
}
示例6: filter_cb
/* A field is a "bomb neighbor" if it has a positive number on its face. */
bool MineFieldFilterBombNeighbours::filter_cb(CoordinateSet coords, Game *field) {
Tile *tile = field->getTile(coords);
if (tile == NULL) return false;
/* The tile must be pressed, not be a mine, and have a positive "surroundings" */
return (tile->getDepressed() && !tile->amIDeadNow() && tile->getSurroundings() > 0);
}