connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts()));
}
delete pPosition;
-
- scoreCounter_.start();
-
-
}
void SeaScene::setupMap(Level level)
if (pPausetextItem_)
pPausetextItem_->hide();
+ scoreCounter_.start();
+
autopauseTimer.start(); //Start counting towards autopause
deviceLockPollTimer_.start(); //Start polling whether device is locked
}
}
// else qDebug() << "No pause text available";
+ levelScore_ += scoreCounter_.elapsed();
+
autopauseTimer.stop(); //No need to count toward autopause when already paused
deviceLockPollTimer_.stop(); //No need to check for unlock as no unpause anyway
}
{
pAboutBoxItem_->hide();
pPausetextItem_->show();
+ return;
}
}
+ //If the game is paused, check if the level completed item is shown
+
+ if (pLevelCompletedItem_)
+ {
+ if (pLevelCompletedItem_->isVisible())
+ {
+ pLevelCompletedItem_->hide();
+ restartLevel(); //Current level has already been set to the next one before showing the level completed item
+ pPauseAction_->setChecked(false); //unpause
+ return;
+ }
+ }
//If the game is paused, check if the victory item is being shown
if(pVictoryCongratulationsItem_)
}
}
+
//If the game is paused and no victory, check if menu item was selected
QList<QGraphicsItem *> items = selectedItems();
void SeaScene::restartLevel()
{
+
+ levelScore_ = 0;
+
setupMap(levelset_.getLevel(currentLevel_)); //getLevel() returns default constructor Level if index is invalid, so no risk of crash
+
+ scoreCounter_.start();
+
vibrationActivate(pVibrateAction_->isChecked()); //Vibration effects are lost without this
// qDebug() << pVibrateAction_->isChecked();
autopauseTimer.start(); //reset counting towards autopause
+
+
}
{
//get score for previous level
- int score = scoreCounter_.elapsed()/1000;
- totalScore_ += score;
+ levelScore_ += scoreCounter_.elapsed();
+ totalScore_ += levelScore_;
int highscore = levelset_.getLevelHighScore(currentLevel_);
+ qDebug() << highscore;
- QString scoretext = tr("Your time: %1 min %2 s<br>Best time: %3 min %4 sec").arg(score/60).arg(score%60).arg(highscore/60).arg(highscore%60);
+ QString scoretext;
+
+ if (levelScore_ >= highscore)
+ {
+ scoretext = tr("<font size=\"5\" color = darkorange>Your time: %1.%2 s<br>Best time: %3.%4 s<br><br>Tap to start the next level").arg(levelScore_/1000).arg((levelScore_%1000)/100).arg(highscore/1000).arg((highscore%1000)/100);
+ }
+
+ else //New high score!
+
+ {
+ scoretext = tr("<font size=\"5\" color = darkorange>Your time %1.%2 s is the new best time!<br>br> Tap to start the next level").arg(levelScore_/1000).arg((levelScore_%1000)/100);
+ levelset_.setLevelHighScore(currentLevel_,levelScore_);
+ }
//pause to show the highscore or victory screen