コード例 #1
0
ファイル: board.cpp プロジェクト: Andre2205p/Program-Grafica
//Define como será o fim do jogo
void Board::fimJogo()
{
    vetorSnakeX.clear();
    vetorSnakeY.clear();
    saveSocore = score;
    run = false;    
    qDebug() << "saveSocore:" << saveSocore;

    if(score == gameOver){ //Você ganhou
        emit salvaScore();
        QSound killSound("Media/tada.wav");
        killSound.play();
        vencedor = true;
        tempo.stop();
        this->update();
    }else if(vida == 2){ //Fim de Jogo
        QSound killSound("Media/tada.wav");
        killSound.play();
        tempo.stop();
        ctrlFim = true;
        end = 'f';
        vida++;
        emit barra_Vida();        
        this->update();
    }else{
        QSound killSound("Media/Windows Critical Stop.wav");
        killSound.play();
        vida ++;
        emit barra_Vida();
        tempo.stop();        
        start();
    }
}
コード例 #2
0
void SoundMixer::removeSound(std::string soundID) {
    for(int i=0; i<sounds.size(); i++) {
        if(sounds[i]->soundID != soundID) {
            continue;
        }
        killSound(sounds[i]);
        sounds.erase(sounds.begin() + i);
        break;
    }
}
コード例 #3
0
ファイル: ofApp.cpp プロジェクト: bgstaal/ofxFFT
void ofApp::initSound(string path) {
    
    killSound();
    
    bool bLoaded = soundPlayer.load(path);
    if(bLoaded == false) {
        return;
    }
    
    sessionDir = ofGetTimestampString("%Y%m%d%H%M%S");
    bool bCreatedDir = ofDirectory::createDirectory(sessionDir);
    if(bCreatedDir == false) {
        return;
    }
    
    ofFile file(path);
    soundBaseName = file.getBaseName();
    soundFileName = file.getFileName();
    file.copyTo(sessionDir + "/" + soundFileName);
    
    fft.startFrameSync(&soundPlayer, numOfSoundFramesPerSecond);
    
    int numOfSoundPixelsTotal = numOfPixelsPerSoundFrame * fft.frameSyncTotal;
    int soundImageSize = sqrt(numOfSoundPixelsTotal);
    soundImageSize = ofNextPow2(soundImageSize);
    
    soundImage.allocate(soundImageSize, soundImageSize, OF_IMAGE_GRAYSCALE);
    soundImage.setColor(ofColor(0, 255));
    soundImage.update();
    
    ofRectangle screenRect(0, 0, ofGetWidth(), ofGetHeight());
    ofRectangle soundImageRect(0, 0, soundImageSize, soundImageSize);
    soundImageRect.scaleTo(screenRect, OF_ASPECT_RATIO_KEEP);
    soundImageRect.x = (int)soundImageRect.x;
    soundImageRect.y = (int)soundImageRect.y;
    soundImageRect.width = (int)soundImageRect.width;
    soundImageRect.height = (int)soundImageRect.height;
    float soundImageScale = soundImageRect.width / (float)soundImageSize;
    
    soundImageMat.makeIdentityMatrix();
    soundImageMat.preMultTranslate(ofVec3f(soundImageRect.x, soundImageRect.y));
    soundImageMat.preMultScale(ofVec3f(soundImageScale, soundImageScale, 1));
    
    ofSetFrameRate(10000);
    ofSetVerticalSync(false);
}