void ButtonsWidget::button_clicked(int number) { qDebug() << "player_iter: [" << player_iter_ << "]" << "numbers_.at(player_iter_) = ["<< numbers_.at(player_iter_) << "]"; if ( numbers_.at(player_iter_) == number ) { //qDebug() << "Correct number: [0] == [" << numbers_.at(player_iter_) << "]"; player_iter_ += 1; correct_ += 1; status_label_->setText(QString("Correct clicks in row: %1").arg(QString::number(correct_))); //qDebug() << "Correct: " << correct_; } else { qDebug() << "Wrong color! Game Over! Correct choice was: [" << numbers_.at(player_iter_) << "]"; stop_game(); } }
void GameScene::update_game(float dt) { if (_state == GameState::PLAYING) { bool game_over{ false }; _robin->update(dt); _tube_spawn_interval -= dt; if (_tube_spawn_interval < 0) { spawn_tube_pair(); _tube_spawn_interval = TUBE_SPAWN_INTERVAL; } if (_robin->getPositionY() < 0) { game_over = true; } else { for (const auto& tube : _tubes) { if (tube->get_state() == TubeState::ACTIVE) { if (_robin->get_tube_collision_box().intersectsRect(tube->getBoundingBox())) { game_over = true; } else if (tube->get_robin_scored() == false) { if (tube->getPositionX() < _robin->getPositionX()) { tube->set_robin_scored(true); _game_score += tube->get_score(); update_score(); } } } } } if (game_over) stop_game(); } }
void Board::update_arrays(){ is_changed = false; int num_of_neighbours; for(int i = 1; i < width_count-1; ++i){ for(int j = 1; j < height_count-1; ++j){ num_of_neighbours = count_neighbours(i, j); if(old_cells[i][j] == DEAD ){ if( num_of_neighbours == 3){ new_cells[i][j] = ALIVE; is_changed = true; } else{ new_cells[i][j] = DEAD; } } else if(old_cells[i][j] == ALIVE){ if (num_of_neighbours == 2 || num_of_neighbours==3){ new_cells[i][j] = ALIVE; } else{ new_cells[i][j] = DEAD; is_changed = true; } } } } if(is_changed == false) stop_game(); for(int i = 1; i < width_count-1; ++i){ for(int j = 1; j < height_count-1; ++j){ old_cells[i][j]=new_cells[i][j]; } } repaint(); }
CALLSET_ENTRY (tilt, sw_slam_tilt) { /* Ignore slam tilt switch entirely while coin door is open, and configured for tournament mode. This is to avoid inadvertent slam tilts while dealing with problems. */ if (system_config.tournament_mode && !switch_poll_logical (SW_COIN_DOOR_CLOSED)) return; /* Ignore right after a coin door open/close */ if (nonball_event_did_follow (sw_coin_door_closed, sw_slam_tilt)) return; /* Kill the current game */ stop_game (); /* Disable coins briefly, the whole point of the slam tilt */ event_can_follow (sw_slam_tilt, sw_coin, TIME_5S); /* Start the slam tilt effect */ callset_invoke (slam_tilt); deff_start (DEFF_SLAM_TILT); leff_restart (LEFF_TILT); /* Audit the event */ audit_increment (&system_audits.slam_tilts); /* When slamtilt penalty adjustment is enabled, remove a credit. */ if (price_config.slamtilt_penalty) remove_credit (); while (deff_get_active () == DEFF_SLAM_TILT) task_sleep (TIME_66MS); /* TODO: wait for slam switch to become stable, to avoid * endless restarts */ warm_reboot (); }