From 7bdc418cb404ca5a32f15a0101ba199d138131fb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Heli=20Hyv=C3=A4ttinen?= Date: Mon, 12 Sep 2011 20:31:56 +0300 Subject: [PATCH] Added total highscore for levelset Also now shows the level score after the last level too. Better position for the level score text for other levels. Conflicts: seascene.cpp seascene.h --- seascene.cpp | 44 +++++++++++++++++++++++++++++++++++--------- seascene.h | 3 ++- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/seascene.cpp b/seascene.cpp index 8ed546a..59a5ddc 100644 --- a/seascene.cpp +++ b/seascene.cpp @@ -117,7 +117,7 @@ void SeaScene::setupMap(int ghosts, int rocks, int octopuses, int octopusSpeed) createAboutBoxItems(); createVictoryItems(); - createLevelCompletedItem(); + createLevelCompletedItems(); //empty the list of moving items @@ -633,19 +633,20 @@ void SeaScene::nextLevel() levelScore_ += scoreCounter_.elapsed(); totalScore_ += levelScore_; int highscore = levelset_.getLevelHighScore(currentLevel_); + qDebug() << highscore; QString scoretext; if (levelScore_ >= highscore) { - 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); + scoretext = tr("Your time: %1.%2 s
Best time: %3.%4 s").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(levelScore_/1000).arg((levelScore_%1000)/100); + scoretext = tr("Your time %1.%2 s is
the new best time!").arg(levelScore_/1000).arg((levelScore_%1000)/100); levelset_.setLevelHighScore(currentLevel_,levelScore_); } @@ -660,6 +661,7 @@ void SeaScene::nextLevel() if ( currentLevel_ < levelset_.numberOfLevels() ) { + pLevelCompletedItem_->setHtml(scoretext); pLevelCompletedItem_->show(); // restartLevel(); @@ -667,6 +669,18 @@ void SeaScene::nextLevel() else //Victory! { + int totalHighsore = levelset_.getTotalHighScore(); + if (totalScore_ >= totalHighsore) + { + scoretext.append(tr("
Your total time: %1.%2 s
Best total time:%3.%4 s").arg(totalScore_/1000).arg((totalScore_%1000)/100).arg(totalHighsore/1000).arg((totalHighsore%1000)/100)); + } + else //new total high score + { + scoretext.append(tr("
Your total time %1.%2 s is
the new best time").arg(totalScore_/1000).arg((totalScore_%1000)/100)); + levelset_.setTotalHighScore(totalScore_); + } + + pVictoryScoreItem_->setHtml(scoretext); pVictoryCongratulationsItem_->show(); } } @@ -700,7 +714,7 @@ void SeaScene::createVictoryItems() pVictoryCongratulationsItem_ = new QGraphicsTextItem; pVictoryCongratulationsItem_->setHtml(" Victory!"); pVictoryCongratulationsItem_->hide(); - pVictoryCongratulationsItem_->setPos(355,50); + pVictoryCongratulationsItem_->setPos(315,30); pVictoryCongratulationsItem_->setZValue(1000); addItem(pVictoryCongratulationsItem_); @@ -709,17 +723,23 @@ void SeaScene::createVictoryItems() QGraphicsTextItem * pTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pTextItem->setHtml(" Congratulations!"); - pTextItem->setPos(-50,100); + pTextItem->setPos(-50,80); pTextItem->setZValue(1000); QGraphicsTextItem * pMiddleTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pMiddleTextItem->setHtml(" You have saved all the ghosts."); - pMiddleTextItem->setPos(-145,140); + pMiddleTextItem->setPos(-145,120); pMiddleTextItem->setZValue(1000); + + pVictoryScoreItem_ = new QGraphicsTextItem(pVictoryCongratulationsItem_); + pVictoryScoreItem_->setPos(-50,180); + pMiddleTextItem->setZValue(1000); + //Text is set at usetime! + QGraphicsTextItem * pLowestTextItem = new QGraphicsTextItem(pVictoryCongratulationsItem_); pLowestTextItem->setHtml(" Tap to play again"); - pLowestTextItem->setPos(-50,220); + pLowestTextItem->setPos(-50,360); pLowestTextItem->setZValue(1000); } @@ -755,6 +775,7 @@ void SeaScene::setItemPointersNull() pAboutBoxItem_ = NULL; pLevelCompletedItem_ = NULL; + pVictoryScoreItem_ = NULL; } @@ -765,11 +786,16 @@ void SeaScene::turnPauseOn() } -void SeaScene::createLevelCompletedItem() +void SeaScene::createLevelCompletedItems() { pLevelCompletedItem_ = new QGraphicsTextItem; addItem(pLevelCompletedItem_); - pLevelCompletedItem_->setPos(20,20); + pLevelCompletedItem_->setPos(240,100); pLevelCompletedItem_->setZValue(1000); pLevelCompletedItem_->hide(); //The text is set at usetime + + QGraphicsTextItem * pTapForNextLevelItem = new QGraphicsTextItem(pLevelCompletedItem_); + pTapForNextLevelItem->setPos(-60,100); + pTapForNextLevelItem->setZValue(1000); + pTapForNextLevelItem->setHtml("Tap to start the next level"); diff --git a/seascene.h b/seascene.h index 7393c1a..c3de5f7 100644 --- a/seascene.h +++ b/seascene.h @@ -100,7 +100,7 @@ protected: void prepareForMenu(QGraphicsItem * pItem); void createAboutBoxItems(); void createVictoryItems(); - void createLevelCompletedItem(); + void createLevelCompletedItems(); const QString ghostImageFilename_; const QString rockImageFilename_; @@ -128,6 +128,7 @@ protected: QGraphicsTextItem * pAboutItem_; QGraphicsTextItem * pQuitItem_; + QGraphicsTextItem * pVictoryScoreItem_; QGraphicsTextItem * pAboutBoxItem_; QGraphicsTextItem * pVictoryCongratulationsItem_; -- 1.7.9.5