void IScene::createScorePopup(int x, int y, int score, bool prepend) { createStaticPopup(QRect(x,y,X56,Y56), QString::number(score), Qt::AlignCenter, gameStock->Font12, Qt::white, 1, 0, 20, 0, -1, prepend); }
void IScene::addTime(int timeAdd) { time += timeAdd; createStaticPopup(QRect(DX(975), DY(75), DX(100), DY(30)), QString("+%1").arg(timeAdd), Qt::AlignLeft | Qt::AlignTop, gameStock->Font20, Qt::yellow, 1, 0, 20, 0, -1 ); }
bool GameScene::initLevel(int level) { qsrand(QTime::currentTime().msec()); // if level pack not found if (max_level == 0) return false; // init field const int max = MAX_COLS*MAX_ROWS; for (int i = 0; i < max; i++) { PlaceInfo &pi = field[i]; if (pi.item) delete pi.item; field[i] = PlaceInfo(); } qDeleteAll(tempItems); tempItems.clear(); rows = cols = 0; currentItem = 0; currentCol = currentRow = -1; targetCol = targetRow = -1; lastClickPos = QPoint(); moveState = MS_IDLE; availFrom = QPoint(); availTo = QPoint(); hintMove = false; hintText = ""; inputDisabled = true; paintState = false; stat_active = false; // set level this->level = level; bonus = 1; bonus_time = 0; time = 10*60; targets = 0; frameCount = 1; // check if all levels were finished if (level > max_level) { showStatictics(STAT_GAME_WON); return true; } // load level from pack if (!loadLevel(level)) return false; // set local info from profile // PlayerInfo *pl = gameProfile->currentPlayer(); LevelPackInfo *lpi = gameProfile->currentPlayer()->currentLevelPackInfo(); score = lpi->score; // more time for hard difficulty if (lpi->diff == DIFF_HARD) time = int(time*1.5); toolset->readProfile(lpi); gameBonus->readProfile(lpi, this); gameBackground->readProfile(gameProfile->currentPlayer()); // add bonus to the timer time += toolset->bonusClock(); stat->level_time = time; gameProfile->setGameStarted(true); gameProfile->setGamePaused(false); // set background loadRandomBackground(); // pre-draw lower layer drawHUDonBackground(); // set cursor setDefaultGameCursor(); // start level createStaticPopup(QRect(0,0,DX(910),DY(700)), tr("Level %1").arg(level), Qt::AlignCenter, gameStock->Font60, Qt::white, 1, 0, 50, 0, -2); sndEngine->playSound(GameSound::sndLevelStart); advanceTimer->start(); // init animation ls_x = ls_y = 0; level_start = true; return true; }