//------------------------------------------------------------------------------------------------- QTDialogSample::QTDialogSample(QWidget* parent) : QDialog(parent) { // Create the UI for the form m_ui = new Ui::Dialog(); m_ui->setupUi(this); //// Set the dialog so that it is not resizable //m_ui->layoutWidget->setFixedSize( sizeHint() ); // Inverval for update on this class (for example to update GUI elements based on app state) m_timer.setInterval(33); //< update the window at 10 Hz m_timer.start(); connect(&m_timer, SIGNAL(timeout()), this, SLOT(Update())); // connect the widgets with the local handlers connect(m_ui->randomBackgroundColor, SIGNAL(clicked()), this, SLOT(setRandomBackgroundColor())); connect(m_ui->whiteLevel, SIGNAL(valueChanged(int)), this, SLOT(setWhiteLevel(int))); }
int Game::update(sf::Event* event) { currentState = State::GAME; if (isGameOver) { score.updateHighScore(); currentState = State::GAME_OVER; } else { handleInput(event); solveCollisions(); for (unsigned i = 0; i < missiles.size(); i++) { if (missiles[i]->getAlive()) { missiles[i]->update(&explosions); } else { delete missiles[i]; missiles.erase(missiles.begin() + i); } } for (unsigned i = 0; i < meteors.size(); i++) { if (meteors[i]->getAlive()) { meteors[i]->update(&explosions); } else { if (meteors[i]->getIsWaveSpawner()) { dropMeteorWave(); } if (!meteors[i]->getReachedDestination()) { score.offsetScore(settings->scoreForMeteor); } delete meteors[i]; meteors.erase(meteors.begin() + i); } } for (unsigned i = 0; i < explosions.size(); i++) { if (explosions[i]->getAlive()) { explosions[i]->update(); } else { delete explosions[i]; explosions.erase(explosions.begin() + i); } } if (nrOfMeteorsLeftTilNextLevel <= 0 && meteors.empty()) { if (currentLevel != 0) { setRandomBackgroundColor(); } increaseLevel(); dropMeteorWave(); } } return currentState; }