From: Heli Hyvättinen Date: Sat, 10 Sep 2011 05:34:55 +0000 (+0300) Subject: The score counting now stops during pauses X-Git-Tag: v0.4.0_Maemo~15 X-Git-Url: http://git.maemo.org/git/?p=ghostsoverboard;a=commitdiff_plain;h=359928b47406498b41f8d0b225784a4fdb5446d1 The score counting now stops during pauses Also moved the starting of the score counting to restart level from setupmap (changes nothing, just a more logical place). --- diff --git a/seascene.cpp b/seascene.cpp index 5adef14..cf14094 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -241,10 +241,6 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed) connect(pOctopus,SIGNAL(droppingGhosts()),pShip,SLOT(dropAllGhosts())); } delete pPosition; - - scoreCounter_.start(); - - } void SeaScene::setupMap(Level level) @@ -378,6 +374,8 @@ void SeaScene::pause(bool paused) if (pPausetextItem_) pPausetextItem_->hide(); + scoreCounter_.start(); + autopauseTimer.start(); //Start counting towards autopause deviceLockPollTimer_.start(); //Start polling whether device is locked } @@ -395,6 +393,8 @@ void SeaScene::pause(bool paused) } // 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 } @@ -620,10 +620,18 @@ void SeaScene::about() 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 + + } @@ -632,23 +640,23 @@ void SeaScene::nextLevel() { //get score for previous level - int score = scoreCounter_.elapsed(); - totalScore_ += score; + levelScore_ += scoreCounter_.elapsed(); + totalScore_ += levelScore_; int highscore = levelset_.getLevelHighScore(currentLevel_); qDebug() << highscore; QString scoretext; - if (score >= highscore) + if (levelScore_ >= highscore) { - scoretext = tr("Your time: %1.%2 s
Best time: %3.%4 s

Tap to start the next level").arg(score/1000).arg((score%1000)/100).arg(highscore/1000).arg((highscore%1000)/100); + scoretext = tr("Your time: %1.%2 s
Best time: %3.%4 s

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("Your time %1.%2 s is the new best time!
br> Tap to start the next level").arg(score/1000).arg((score%1000)/100); - levelset_.setLevelHighScore(currentLevel_,score); + scoretext = tr("Your time %1.%2 s is the new best time!
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 diff --git a/seascene.h b/seascene.h index c5fe8f8..faa5360 100644 --- a/seascene.h +++ b/seascene.h @@ -163,6 +163,7 @@ protected: QTime scoreCounter_; int totalScore_; + int levelScore_; };