Ejemplo n.º 1
0
void GameScene::setLevel(int level) {
    m_level = level;
    qDebug() << "Starting level" << level;

    lastSpecialSpawnTime = 0;
    setTimeFactor(normalTimeFactor);

    foreach(QGraphicsItem *item, items()) {
        if(Particle* particle = qgraphicsitem_cast<Particle*>(item)) {
            removeItem(particle);
            delete particle; // Delete the particle completely. Should (hopefully) not be referenced anywhere else.
        }
    }

    if(gameMode() == ModeClassic && level == 1) {

        setRemainingPositiveCharges(20);
        setRemainingNegativeCharges(20);

        setLevelTime(27);
    } else if(gameMode() == ModeClassic) {
        setLevelTime(baseTime + (int)(timeIncrement * level));
        setRemainingPositiveCharges(baseChargeNum + (int)(incrementChargeNum * level));
        setRemainingNegativeCharges(baseChargeNum + (int)(incrementChargeNum * level));
    } else if(gameMode() == ModeParty) {
        setLevelTime(baseTimeParty + (int)(timeIncrementParty * level));
        setRemainingPositiveCharges(baseChargeNumPositiveParty + (int)(incrementChargeNumParty * level));
        setRemainingNegativeCharges(baseChargeNumNegativeParty + (int)(incrementChargeNumParty * level));
        specialParticles()->clear();
        if(level == 14) {
            specialParticles()->append(Particle::ParticleTransfer);
        }
        setRemainingSpecialCharges(specialParticles()->count());
    } else {
        qWarning() << "Some unknown mode is set!";
    }

    // set text of remaining charges
    updateRemainingChargeText();

    // add player
    player = new Particle(this);
#ifndef BENCHMARK
    addItem(player);
#endif
    player->setCharge(playerCharge * (1 + levelChargeFactor * pow((double)level,2)));
    player->setParticleType(Particle::ParticlePlayer);
    if(gameMode() == ModeClassic && level == 1) {
        player->setPosition(QVector2D(gameRectF().width() * 0.9,gameRectF().height() * 0.9));
    } else {
        player->setPosition(QVector2D(gameRectF().width() / 2,gameRectF().height() / 2));
    }

    // add enemies
    addEnemies();

    // Notify everyone about the level change
    emit levelChanged(level);
}
Ejemplo n.º 2
0
NxCursor::NxCursor(NxObjectFactoryInterface *parent, QTreeWidgetItem *ccParentItem, UiRenderOptions *_renderOptions) :
    NxObject(parent, ccParentItem, _renderOptions) {
    glListCursor = glGenLists(1);
    curve = 0;
    setTimeLocal(0);
    nextTimeOld = 0;
    timeOld = 0;
    time = 0;
    timeLocal = 0;
    timeLocalOld = 0;
    timeLocalAbsolute = 0;
    previousCursorReliable = false;
    previousPreviousCursorReliable = false;
    cursorAngleCacheSinZ = cursorAngleCacheCosZ = cursorAngleCacheSinY = cursorAngleCacheCosY = 0;
    cursorPoly       = NxPolygon(4);
    cursorPoly[0]    = NxPoint();
    cursorPoly[1]    = NxPoint();
    cursorPoly[2]    = NxPoint();
    cursorPoly[3]    = NxPoint();
    cursorPolyOld    = NxPolygon(4);
    cursorPolyOld[0] = NxPoint();
    cursorPolyOld[1] = NxPoint();
    cursorPolyOld[2] = NxPoint();
    cursorPolyOld[3] = NxPoint();
    setNbLoop(0);
    setStart("1 0");
    setTimeFactor(1);
    setTimeFactorF(1);
    setWidth(1);
    setDepth(0);
    setTime(0);
    setSize(1.2);
    setLineFactor(1);
    setLineStipple(0xFFFF);
    setColorActive("cursor_active");
    setColorInactive("cursor_inactive");
    setTimeStartOffset(0);
    setTimeEndOffset(0);
    setTimeInitialOffset(0);
    setEasing(0);
    setBoundsSource("-10 10 -10 10 -10 10");
    setBoundsTarget("0 1 0 1 0 1");
    boundsSourceIsBoundingRect = true;
}