Example #1
0
void Scene::changeScene(QString tileInfo, int tileSpecial){
    if (getBackground() != tileInfo){
        setBackground(tileInfo);
        QVariant newID (tileInfo);
        sendImageID(newID);

        if (tileSpecial != 0){
            if (tileSpecial == 1 || tileSpecial == 2){
                spawnChest(tileSpecial);
            }
            else if (tileSpecial == 3){
                spawnNPC(tileSpecial);
            }
        }
        else {
            spawnEnemy();
        }
    }
}
Example #2
0
void LevelScene::placeItemByMouse(int x, int y)
{
    if(!placingMode) return;
    for(int i=0;i<cameras.size(); i++)
    {
        PGE_Rect camRect;
        camRect.setRect(0, cameras[i].h()*i, cameras[i].w(), cameras[i].h());
        if(camRect.collidePoint(x, y))
        {
            x+=cameras[i].posX();
            y+=cameras[i].posY();
            break;
        }
    }

    qDebug()<<"Placed:" << placingMode_item_type<<" in pos:" << x << y;

    switch(placingMode_item_type)
    {
        case 0:
            placingMode_block.x=x;
            placingMode_block.y=y;
            spawnBlock(placingMode_block);
            break;
        case 1:
            placingMode_bgo.x=x;
            placingMode_bgo.y=y;
            spawnBGO(placingMode_bgo);
            break;
        case 2:
            placingMode_npc.x=x;
            placingMode_npc.y=y;
            spawnNPC(placingMode_npc, GENERATOR_APPEAR, SPAWN_UP);
            break;
    }
}