{
QSettings settings;
settings.beginGroup(name_);
- return settings.value("TotalHighScore",54000*10).toInt();
+ return settings.value("TotalHighScore",900*100).toInt();
}
void Levelset::setTotalHighScore(int highscore)
QString group = name_.append("/LevelHighScore");
settings.beginGroup(group);
- return settings.value(QString(index),54000).toInt();
+ return settings.value(QString(index),900).toInt();
}
void Levelset::setLevelHighScore(int index, int highScore)
currentLevel_ = 0;
+ totalScore_ = 0;
+
connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()));
createVictoryItems();
+ createLevelCompletedItem();
+
//empty the list of moving items
}
delete pPosition;
+ scoreCounter_.start();
+
}
void SeaScene::nextLevel()
{
- currentLevel_++;
+ //get score for previous level
+ int score = scoreCounter_.elapsed()/1000;
+ totalScore_ += score;
+ int highscore = levelset_.getLevelHighScore(currentLevel_);
+
+ 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);
- if (!levelset_.isValid())
- setupMap(Level());
+ //pause to show the highscore or victory screen
+ turnPauseOn();
+ pPausetextItem_->hide();
+
+
+ //Go to the next level if available
+ currentLevel_++;
if ( currentLevel_ < levelset_.numberOfLevels() )
{
- restartLevel();
+ pLevelCompletedItem_->setHtml(scoretext);
+ pLevelCompletedItem_->show();
+// restartLevel();
}
else //Victory!
{
-
- pPauseAction_->setChecked(true); //Pause the game while showing the victory dialog
-
- pPausetextItem_->hide();
-
pVictoryCongratulationsItem_->show();
-
}
}
void SeaScene::restartGame()
{
currentLevel_ = 0;
+ totalScore_ = 0;
restartLevel();
}
pAboutBoxItem_ = NULL;
pVictoryCongratulationsItem_ = NULL;
+ pLevelCompletedItem_ = NULL;
+
}
}
}
}
+
+void SeaScene::createLevelCompletedItem()
+{
+ pLevelCompletedItem_ = new QGraphicsTextItem;
+ addItem(pLevelCompletedItem_);
+ pLevelCompletedItem_->setPos(20,20);
+ pLevelCompletedItem_->setZValue(1000);
+ pLevelCompletedItem_->hide();
+ //The text is set at usetime
+
+}
#include <QAction>
#include <QTimer>
#include <QSystemDeviceInfo>
+#include <QTime>
using namespace QtMobility;
void softContinue();
- void createAboutBoxItems();
-
- void createVictoryItems();
-
void setItemPointersNull();
void turnPauseOn();
void createMenuItems();
void prepareForMenu(QGraphicsItem * pItem);
+ void createAboutBoxItems();
+ void createVictoryItems();
+ void createLevelCompletedItem();
const QString ghostImageFilename_;
const QString rockImageFilename_;
QGraphicsTextItem * pVictoryCongratulationsItem_;
QGraphicsTextItem * pAboutBoxItem_;
+ QGraphicsTextItem * pLevelCompletedItem_;
+
Levelset levelset_;
QTimer deviceLockPollTimer_;
+ QTime scoreCounter_;
+ int totalScore_;
+
};
#endif // SEASCENE_H