本文整理汇总了C++中Obstacle::setVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::setVisible方法的具体用法?C++ Obstacle::setVisible怎么用?C++ Obstacle::setVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obstacle
的用法示例。
在下文中一共展示了Obstacle::setVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAddition
void Game::checkAddition()
{
if (addWallCounter >= addWallLimit)
{
addWallCounter = 0;
int r = rand() % 100;
if (r < TWO_WALL_PROB)
{
// add two walls
Wall* a = new Wall(0, 0);
Wall* b = new Wall(VIEW_WIDTH - WALL_WIDTH, 0);
myObjects.append(a);
myObjects.append(b);
myScene.addItem(a);
myScene.addItem(b);
a->setVisible(true);
b->setVisible(true);
}
else if (TWO_WALL_PROB <= r
&& r < TWO_WALL_PROB + LEFT_WALL_ONLY_PROB)
{
// add a wall on the left and a gap on the right
Wall* a = new Wall(0, 0);
Gap* b = new Gap(VIEW_WIDTH - WALL_WIDTH, 0);
myObjects.append(a);
myObjects.append(b);
myScene.addItem(a);
myScene.addItem(b);
a->setVisible(true);
b->setVisible(true);
}
else
{
// add a gap on the left and a wall on the right
Gap* a = new Gap(0, 0);
Wall* b = new Wall(VIEW_WIDTH - WALL_WIDTH, 0);
myObjects.append(a);
myObjects.append(b);
myScene.addItem(a);
myScene.addItem(b);
a->setVisible(true);
b->setVisible(true);
}
}
else
{
addWallCounter ++;
}
if (addObstCounter >= addObstLimit)
{
addObstCounter = 0;
int r = rand() % 100;
if (r < OBSTACLE_PROB)
{
// add an obstacle
int coordinate = rand() % (VIEW_WIDTH - OBSTACLE_WIDTH
- 2*WALL_WIDTH - 2*PLAYER_WIDTH
- 6) + WALL_WIDTH + PLAYER_WIDTH + 3;
Obstacle* a = new Obstacle(coordinate, 0);
myObjects.append(a);
myScene.addItem(a);
a->setVisible(true);
}
}
else
{
addObstCounter ++;
}
}