예제 #1
0
void LevelManager::initLevelData() {
    
    levelData[0] = LevelData(300);
    levelData[1] = LevelData(400);
    levelData[2] = LevelData(500);
    levelData[3] = LevelData(600);
    levelData[4] = LevelData(700);
}
예제 #2
0
bool CLevel::DustBlock(const CCoord<int>& aPos) const
{
	int num = LevelData(aPos).iNumber;
	for (int a=0;a<KDustBlockAmount;a++) 
		if (num==KDustBlocks[a]) 
		{
			return true;
		}

	return false;
}
예제 #3
0
void CLevel::DarknessCast()
{
	int a,b;

	// Leave borders out
	for(a=1;a<iHeight-1;a++)
		for(b=1;b<iWidth-1;b++)
			if (LevelData(b,a).iHeight == 0) 
					iLevelData[a*iWidth+b].iCastDarkness=0;
				else 
					iLevelData[a*iWidth+b].iCastDarkness=1;
}
예제 #4
0
void LvlHistoryManager::addRemove(LevelData removedItems)
{
    //add cleanup redo elements
    updateHistoryBuffer();
    //add new element
    HistoryElementModification* modf = new HistoryElementModification(removedItems, LevelData());
    modf->setCustomHistoryName(tr("Remove"));
    modf->setScene(m_scene);
    operationList.push_back(QSharedPointer<IHistoryElement>(modf));
    historyIndex++;

    emit refreshHistoryButtons();
}
예제 #5
0
void GameState::loadLevelsData()
{
    std::vector<std::string> data = tokenize(loadFile("levels.txt"), "\n", true);

    if (data.size() == 0)
    {
        throw DBSH07_EXCEPTION("levels.txt is empty!");
    }

    int numberOfLevels = 0;
    int numberOfBonusLevels = 0;
    for (unsigned int i = 0; i < data.size(); i++)
    {
        std::vector<std::string> row = tokenize(data[i], " ");

        if (row.size() < 2)
        {
            throw DBSH07_EXCEPTION("Corrupt levels.txt file at row " + toString(i) + ".");
        }

        if (row[0] == "N")
        {
            numberOfLevels++;
            mLevelsData.push_back(LevelData(row[1], false, "LEVEL " + toString(numberOfLevels)));
        }
        else if (row[0] == "B")
        {
            numberOfBonusLevels++;
            mLevelsData.push_back(LevelData(row[1], true, "BONUS LEVEL " + toString(numberOfBonusLevels)));
        }
        else
        {
            throw DBSH07_EXCEPTION("Corrupt levels.txt file at row " 
                                    + toString(i) +". Unknown token " + row[0] + ".");
        }
    }
}
예제 #6
0
    virtual void onSceneLoadToMemory() {
        texTREX.loadFromFile("files/textures/icons/trex.png");
        texJumper.loadFromFile("files/textures/icons/jumper.png");
        texSynth3d.loadFromFile("files/textures/icons/synth3de.png");
        texMario.loadFromFile("files/textures/icons/mario.png");
        texRpg.loadFromFile("files/textures/icons/RPG.png");
        texShooter2d.loadFromFile("files/textures/icons/shooter2d.png");
        texDisco.loadFromFile("files/textures/icons/iSayParty.png");

        texBackground.loadFromFile("files/textures/icons/background.png");

        vecLvlData.push_back(LevelData("Trex", "TREX", &texTREX));
        vecLvlData.push_back(LevelData("Jumper", "JUMPER", &texJumper));
        vecLvlData.push_back(LevelData("Synth3D", "SYNTH3D", &texSynth3d));
        vecLvlData.push_back(LevelData("Mario", "MARIO2", &texMario));
        vecLvlData.push_back(LevelData("Rpg", "RPG", &texRpg));
        vecLvlData.push_back(LevelData("Shooter 2D", "SHOOTER2D", &texShooter2d));
        vecLvlData.push_back(LevelData("Dance Party", "ISAYPARTY", &texDisco));

        int sWidth = vecLvlData[0].sprite.getGlobalBounds().width, sHeight = vecLvlData[0].sprite.getGlobalBounds().height;

        vecLvlData[0].sprite.setPosition(window->getSize().x*0.25f, window->getSize().y*0.25f);
        vecLvlData[1].sprite.setPosition(window->getSize().x*0.2f, window->getSize().y*0.5f);
        vecLvlData[2].sprite.setPosition(window->getSize().x*0.3f, window->getSize().y*0.72f);
        vecLvlData[3].sprite.setPosition(window->getSize().x*0.5f, window->getSize().y*0.8f);
        vecLvlData[4].sprite.setPosition(window->getSize().x*0.7f, window->getSize().y*0.7f);
        vecLvlData[5].sprite.setPosition(window->getSize().x*0.8f, window->getSize().y*0.55f);
        vecLvlData[6].sprite.setPosition(window->getSize().x*0.7f, window->getSize().y*0.25f);

        backgroundTexture.loadFromFile("files/textures/icons/background.png");
        logoTexture.loadFromFile("files/textures/icons/logo.png");

        backgroundSprite = sf::Sprite(backgroundTexture);
        logoSprite = sf::Sprite(logoTexture);
        logoSprite.setScale(5.0, 5.0);
        logoSprite.setPosition(window->getSize().x/2-logoSprite.getGlobalBounds().width/2, margin+100);

        spsLeft.loadFromFile("files/textures/icons/playerLeft.png");
        spsRight.loadFromFile("files/textures/icons/playerRight.png");
        aLeft.setSpriteSheet(&spsLeft, 5, sf::milliseconds(500));
        aRight.setSpriteSheet(&spsRight, 5, sf::milliseconds(500));
        aspPlayer.setAnimation(&aLeft);

        aspPlayer.setScale(5.0f, 5.0f);
        aspPlayer.setPosition(window->getSize().x/2.0 - sWidth/2.0, window->getSize().y/2.0 - sHeight/2.0);
    }
예제 #7
0
/**
* ModifyBorderBlocks: Jos joku reunablockeista on matalampi kuin outblock, niin
* se korotetaan outblockin tasolle. Tämä siksi että grafiikka ei bugita...
* Lisäksi mahdolliset lattia palikat muunnetaan seinäksi...
*/
void CLevel::ModifyBorderBlocks()
{
	int a;
	for (a=0;a<Height();a++)
	{
		if (LevelData(0,a).iType==EBlockTypeFloor) 
			LevelData(0,a).iType= EBlockTypeWall;
		if (LevelData(Width()-1,a).iType==EBlockTypeFloor)
			LevelData(Width()-1,a).iType= EBlockTypeWall;

		ASSERT( iOutBlock.iNumber < KBlockHeightTableSize );

		if (LevelData(0,a).iHeight<KBlockHeights[iOutBlock.iNumber]) 
			LevelData(0,a).iHeight =  KBlockHeights[iOutBlock.iNumber];
		if (LevelData(Width()-1, a).iHeight<KBlockHeights[iOutBlock.iNumber]) 
			LevelData(Width()-1, a).iHeight = KBlockHeights[iOutBlock.iNumber];
	}
	for (a=0;a<Width();a++)
	{
		if (LevelData(a,0).iType==EBlockTypeFloor) 
			LevelData(a,0).iType= EBlockTypeWall;
		if (LevelData(a,Height()-1).iType==EBlockTypeFloor) 
			LevelData(a,Height()-1).iType= EBlockTypeWall;
		
		ASSERT( iOutBlock.iNumber < KBlockHeightTableSize );

		if (LevelData(a,0).iHeight<KBlockHeights[iOutBlock.iNumber]) 
			LevelData(a,0).iHeight = KBlockHeights[iOutBlock.iNumber];
		if (LevelData(a, Height()-1).iHeight<KBlockHeights[iOutBlock.iNumber]) 
			LevelData(a, Height()-1).iHeight = KBlockHeights[iOutBlock.iNumber];
	}
}