|
yafeilinux 发表于 2013-10-30 19:39
这个写个函数就可以了啊。会写前面几个等级了,后面照着写就行啊,根据自己的设置,让分数一直加,加到一定 ...
我是按社区的代码做的,用最原代码的方法实现了,我就设置了6个等级,分数可以增加,用for 循环来做等级的上升可以吗?给一些思路。
/ 更新分数
void MyView::updateScore(const int fullRowNum)
{
int score = fullRowNum * 100;
int currentScore = gameScoreText->toPlainText().toInt();
currentScore += score;
// 显示当前分数
gameScoreText->setHtml(tr("<font color=red>%1</font>").arg(currentScore));
// 判断级别
if (currentScore < 500) {
// 第一级,什么都不用做
} else if (currentScore < 1000) { // 第二级
gameLevelText->setHtml(tr("<font color=white>第<br>二<br>幕</font>"));
scene()->setBackgroundBrush(QPixmap(":/images/background02.png"));
gameSpeed = 300;
boxGroup->stopTimer();
boxGroup->startTimer(gameSpeed);
if (QFileInfo(backgroundMusic->currentSource().fileName()).baseName()
!= "background02") {
backgroundMusic->setCurrentSource(Phonon::MediaSource(SOUNDPATH + "background02.mp3"));
backgroundMusic->play();
}
} else {
// 添加下一个级别的设置
if (currentScore < 1000) { // 第二级
} else if (currentScore < 1500) { // 第3J
gameLevelText->setHtml(tr("<font color=white>第<br>三<br>幕</font>"));
scene()->setBackgroundBrush(QPixmap(":/images/Water lilies.jpg"));
gameSpeed = 300;//方块的下落速度
boxGroup->stopTimer();
boxGroup->startTimer(gameSpeed);
}else {
if (currentScore < 1500) { // 第3J
} else if (currentScore < 2000) { // 第四级
gameLevelText->setHtml(tr("<font color=white>第<br>四<br>幕</font>"));
scene()->setBackgroundBrush(QPixmap(":/images/t019.jpg"));
gameSpeed = 200;//方块的下落速度
boxGroup->stopTimer();
boxGroup->startTimer(gameSpeed);
}else{
if (currentScore < 2000) { // 第3J
} else if (currentScore < 2500) { // 第四级
gameLevelText->setHtml(tr("<font color=white>第<br>五<br>幕</font>"));
scene()->setBackgroundBrush(QPixmap(":/images/t019.jpg"));
gameSpeed = 100;//方块的下落速度
boxGroup->stopTimer();
boxGroup->startTimer(gameSpeed);
}else{
if (currentScore < 2000) { // 第五级
} else if (currentScore < 2500) { // 第六级
gameLevelText->setHtml(tr("<font color=white>第<br>六<br>幕</font>"));
scene()->setBackgroundBrush(QPixmap(":/images/t019.jpg"));
gameSpeed = 90;//方块的下落速度
boxGroup->stopTimer();
boxGroup->startTimer(gameSpeed);
}
}
}
}
}
}
|
|