Esempio n. 1
0
void MainWindow::slotPlaybackNextFrame()
{
    if (isLastFrame())
    {
        slotPlaybackPause();
    }
    else
    {
        slotGotoFrame(++currentFrameIndex);
    }
}
void WhitePlayer::update() {

    Player::processInput();

    if(lastPlayerToShoot.c_str() == pName && ball->hasScored() && !hasScored) {
        if((pShotPosition <= 553 && !isChangingPerspective)
                || (isChangingPerspective && pInitialY == 403)
                || (isChangingPerspective && pShotPosition <= 553)){
            if(pScore + 2 >= 21) {
                pScore = 21;
                if(!isTheWinner) {
                    isTheWinner = true;
                }
            }
            else {
                pScore += 2;
            }
        }
        else {
            if(pScore + 1 >= 21) {
                pScore = 21;
                if(!isTheWinner) {
                    isTheWinner = true;
                }
            }
            else {
                pScore++;
            }
        }
        pCurrentScore = scoreTextures[pScore];
        hasScored = true;
    }

    if(isRunning && !isDefending && !hasTheBall) {
        if(currFrameTime == frameTime) {
            frame++;
            currFrameTime = 0;
        }
        else {
            currFrameTime++;
        }
        if(isLastFrame(RUNNING)) {
            frame = 0;
        }
        pTexture = runningTextures[frame];
    }
    else if(isRunning && isDefending && !hasTheBall) {
        if(currFrameTime == frameTime) {
            frame++;
            currFrameTime = 0;
        }
        else {
             currFrameTime++;
        }
        if(isLastFrame(DEFENDING)) {
            frame = 0;
        }
        pTexture = defenceTextures[frame];
        if(!positioned) {
            pPos.y += 20;
            positioned = true;
        }
    }
    else if(isDefending && isStanding && !hasTheBall && !isStealing) {
        pTexture = pDefenceStance;
        if(!positioned) {
            pPos.y += 20;
            positioned = true;
        }
    }
    else if(isDefending && isStanding && !hasTheBall && isStealing) {
        if(currFrameTime == frameTime) {
            frame++;
            currFrameTime = 0;
        }
        else {
             currFrameTime++;
        }
        if(isLastFrame(STEALING)) {
            frame = 0;
            isStealing = false;
        }
        pTexture = stealingTextures[frame];
        if(!positioned) {
            pPos.y += 20;
            positioned = true;
        }
    }
    else if(isJumping && !hasTheBall) {
        if(currFrameTime == frameTime) {
            frame++;
            currFrameTime = 0;
        }
        else {
             currFrameTime++;
        }
        if(isLastFrame(JUMPING)) {
            frame=JUMPING-1;
        }
        pTexture = jumpingTextures[frame];
    }
    else if(hasTheBall && isStanding) {
        if(currFrameTime == frameTime) {
            frame++;
            if(frame == 8) {
                Mix_PlayChannel(-1, dribble, 0);
            }
            currFrameTime = 0;
        }
        else {
            currFrameTime++;
        }
        if(isLastFrame(STANDDRIBBLE)) {
            frame = 0;
        }
        pTexture = standDribbleTextures[frame];
    }
    else if(hasTheBall && isRunning) {
//        if(currFrameTime == frameTime) {
//            frame++;
//            currFrameTime = 0;
//        }
//        else {
//            currFrameTime++;
//        }
        if(isLastFrame(DRIBBLING)) {
            frame = 0;
        }
        pTexture = dribblingTextures[frame];
        if(frame == 10) {
            Mix_PlayChannel(-1, dribble, 0);
        }
        frame++;
    }
    else if(hasTheBall && isJumping) {
        if(currFrameTime == frameTime) {
            frame++;
            currFrameTime = 0;
        }
        else {
            currFrameTime++;
        }
        if(isLastFrame(SHOOT)) {
            frame = SHOOT-1;
        }
        pTexture = shootingTextures[frame];
    }
    else if(isStanding && !hasTheBall) {
//        if(!stancePositioned) {
//            stancePositioned = true;
//            pPos.y -= 10;
//        }
    }
}