本文整理汇总了C++中Level::eatenPellets方法的典型用法代码示例。如果您正苦于以下问题:C++ Level::eatenPellets方法的具体用法?C++ Level::eatenPellets怎么用?C++ Level::eatenPellets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Level
的用法示例。
在下文中一共展示了Level::eatenPellets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onPelletEaten
void Game::onPelletEaten()
{
m_score += 10;
Level *level = m_levels.at(m_currentLevel);
int eatenPellets = level->eatenPellets() +1;
level->setEatenPellets(eatenPellets);
switch (eatenPellets) {
case 30: inky->setFree(true);
break;
case 80: clyde->setFree(true);
break;
}
}
示例2: nextGameFrame
void Game::nextGameFrame()
{
static float chaseTimer = 0.0;
static QTime lastFrameTime;
if(!lastFrameTime.isNull())
{
chaseTimer += lastFrameTime.msecsTo(QTime::currentTime())/1000.0;
}
lastFrameTime = QTime::currentTime();
Level *level = m_levels.at(m_currentLevel);
// Mouvements
QList<Ghost*> collision;
level->movePacman();
level->moveGhosts();
collision.append(level->checkUnitsPositions());
level->updateTimer();
//
if(level->eatenPellets() == level->pelletCount())
{
m_timer->stop();
m_currentLevel++;
if(m_currentLevel == m_levels.size())
{
m_victory = true;
emit gameFinished();
return;
}
else
{
m_isChangingLevel = true;
m_currentLevelImageReady = false;
Level *level = m_levels.at(m_currentLevel);
level->startLevel();
return;
}
}
if(collision.size() > 0)
{
if(!Ghost::areGhostsScared())
{
m_lifes--;
if(m_lifes>0)
{
level->resetUnitsPosition();
}
else
{
m_defeat = true;
emit gameFinished();
return;
}
m_timer->stop();
}
else
{
for(int i=0; i<collision.size(); i++)
{
m_score += 200 * qPow(2, m_consecutivesEnergizers);
m_consecutivesEnergizers ++;
QTimer::singleShot(500, this, SLOT(resumeGame()));
m_timer->stop();
}
}
}
if(!Ghost::areGhostsScared())
m_consecutivesEnergizers = 0;
QPixmap *image = level->render();
m_image = *image;
delete image;
m_currentLevelImageReady = true;
}