Can show time used for level and what high score was before it.
No longer knows how to advance to the next level.
Does not update high score.
Conflicts:
seascene.cpp
seascene.h
{
QSettings settings;
settings.beginGroup(name_);
{
QSettings settings;
settings.beginGroup(name_);
- return settings.value("TotalHighScore",54000*10).toInt();
+ return settings.value("TotalHighScore",900*100).toInt();
}
void Levelset::setTotalHighScore(int highscore)
}
void Levelset::setTotalHighScore(int highscore)
QString group = name_.append("/LevelHighScore");
settings.beginGroup(group);
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)
}
void Levelset::setLevelHighScore(int index, int highScore)
//This ensures that nextlevel will not be called until its safe to delete the Ship object.
//Leaving out Qt::QueuedConnection or calling nextlevel directly instead of emitting the signal will CRASH
connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
//This ensures that nextlevel will not be called until its safe to delete the Ship object.
//Leaving out Qt::QueuedConnection or calling nextlevel directly instead of emitting the signal will CRASH
connect(this,SIGNAL(allGhostsPicked()),this,SLOT(nextLevel()),Qt::QueuedConnection);
createAboutBoxItems();
createVictoryItems();
createAboutBoxItems();
createVictoryItems();
+ createLevelCompletedItem();
+
//empty the list of moving items
//empty the list of moving items
+ scoreCounter_.start();
+
void SeaScene::nextLevel()
{
void SeaScene::nextLevel()
{
+ //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() )
{
if ( currentLevel_ < levelset_.numberOfLevels() )
{
+ pLevelCompletedItem_->setHtml(scoretext);
+ pLevelCompletedItem_->show();
+// restartLevel();
-
- pPauseAction_->setChecked(true); //Pause the game while showing the victory dialog
-
- pPausetextItem_->hide();
-
pVictoryCongratulationsItem_->show();
pVictoryCongratulationsItem_->show();
void SeaScene::restartGame()
{
currentLevel_ = 0;
void SeaScene::restartGame()
{
currentLevel_ = 0;
// pMinimizeItem_ = NULL; //Fremantle spesific
pAboutBoxItem_ = NULL;
// pMinimizeItem_ = NULL; //Fremantle spesific
pAboutBoxItem_ = NULL;
+ pLevelCompletedItem_ = NULL;
+
}
void SeaScene::turnPauseOn()
{
pPauseAction_->setChecked(true);
}
}
void SeaScene::turnPauseOn()
{
pPauseAction_->setChecked(true);
}
+
+}
+
+void SeaScene::createLevelCompletedItem()
+{
+ pLevelCompletedItem_ = new QGraphicsTextItem;
+ addItem(pLevelCompletedItem_);
+ pLevelCompletedItem_->setPos(20,20);
+ pLevelCompletedItem_->setZValue(1000);
+ pLevelCompletedItem_->hide();
+ //The text is set at usetime
#include "levelset.h"
#include <QAction>
#include <QTimer>
#include "levelset.h"
#include <QAction>
#include <QTimer>
class SeaScene : public QGraphicsScene
{
class SeaScene : public QGraphicsScene
{
- void createAboutBoxItems();
- void createVictoryItems();
-
void setItemPointersNull();
void turnPauseOn();
void setItemPointersNull();
void turnPauseOn();
void createMenuItems();
void prepareForMenu(QGraphicsItem * pItem);
void createMenuItems();
void prepareForMenu(QGraphicsItem * pItem);
+ void createAboutBoxItems();
+ void createVictoryItems();
+ void createLevelCompletedItem();
const QString ghostImageFilename_;
const QString rockImageFilename_;
const QString ghostImageFilename_;
const QString rockImageFilename_;
QGraphicsTextItem * pAboutBoxItem_;
QGraphicsTextItem * pVictoryCongratulationsItem_;
QGraphicsTextItem * pAboutBoxItem_;
QGraphicsTextItem * pVictoryCongratulationsItem_;
+ QGraphicsTextItem * pLevelCompletedItem_;
+
+
+ QTime scoreCounter_;
+ int totalScore_;