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 ++; } }