void GravityJamRoot::endLevel(float dt)
{
    // we will need all of the end of level graphics here
    // for now, just unload the level and load the next one
    closeLevel();
    if(!nextLevel())
    {
        printf("Error opening level %i", gj_level);
        faulted = true;
    }
}
Exemple #2
0
bool Game::nextLevel(){
    closeLevel();

    if(loadLevel(currentLevel++)){ //jesli znaleziono kolejny poziom
        showTitleText(QString("Gratulacje, przeszedles poziom ") +  QString::number(currentLevel-1));
        return true;
    }else{ //w przeciwnym razie ustawia poziom na zerowy
        loadLevel((this->currentLevel = 0)++);
        showTitleText(QString("Gratulacje, przeszedles cala gre !"));
    }
    return false;
}
Exemple #3
0
void KBounceGameWidget::closeGame()
{
    if ( m_state != BeforeFirstGame && m_state != GameOver )
    {
        closeLevel();
        unsetCursor();
        m_state = GameOver;
        emit stateChanged( m_state );
        emit gameOver();

        redraw();
    }
}
Exemple #4
0
void KBounceGameWidget::onFillChanged( int fill )
{
    emit filledChanged( fill );
    if ( fill >= MIN_FILL_PERCENT )
    {
        closeLevel();
        m_level++;
        emit levelChanged( m_level );

        m_state = BetweenLevels;
        emit stateChanged( m_state );

        redraw();
    }
}
Exemple #5
0
    // Loads the current level from its name.
    // If it already exist, it is erased and replaced.
    // Returns the loaded level (if loading succeeded).
    Level * LevelManager::openLevel(std::string name) throw(GameException)
    {
        std::cout << "Loading level..." << std::endl;

        std::string levelPath = "worlds/world/" + name;
        adaptFilePath(levelPath);
        std::ifstream ifs(levelPath.c_str(), std::ios::in | std::ios::binary);
        if(ifs.good())
        {
            if(isLevel())
                closeLevel();

            m_level = new Level();
            m_level->unserialize(ifs);

            ifs.close();
        }
        else
        {
            throw GameException("LevelManager::loadLevel: Cannot load level '" + levelPath + "'");
        }
        std::cout << "Level loaded" << std::endl;
        return getLevel();
    }
Exemple #6
0
 ~LevelManager()
 {
     if(isLevel())
         closeLevel();
 }
Exemple #7
0
 // Creates the current level from specified information.
 // If it already exist, it is erased and replaced.
 // Returns the created level.
 Level * LevelManager::createLevel(const LevelInfo & info)
 {
     closeLevel();
     m_level = new Level(info);
     return m_level;
 }