//--------------------------------------------------------------
void ofApp::setup(){
    serial.listDevices();
    bool connectionStatus = connectToArduino();
    ofLog() << "Connect To Arduino returned: " << connectionStatus;
    if(!connectionStatus){
        ofExit();
    }

    cubes = vector<Cube>(nrCubes, Cube());
    //place the cubes
    for(int i = 0; i < nrCubes; i++){
        cubes[i].setup(i, this);
    }
    updateCubes();

    ofAddListener(Cube::cubeTriggered, this, &ofApp::onCubeTriggered);
    ofAddListener(CopyBridge::copyingDone, this, &ofApp::onCopyingDone);

    seq = new Sequencer(this, 120);

    //GUI
    gui.setup();
    run.addListener(this, &ofApp::toggleSequencer);
    gui.add(run.setup("run sequencer", false));
    tempo.addListener(this, &ofApp::setTempo);
    gui.add(tempo.setup("tempo", 120, 80, 140));
}
Exemplo n.º 2
0
/** Check if the cube is still rotating. If it just finished, update the cubes. */
void updateRotationProgress() {
	if (IS_ROTATING) 
		rotationProgress = ((float)glutGet(GLUT_ELAPSED_TIME)-rotationStartTime)/ROTATION_DURATION;
	if (rotationProgress >= 1.0 && !finishedRotating) {
		rotationProgress = 1.0;
		updateCubes();
	}
}
//--------------------------------------------------------------
void ofApp::update(){
    if(serial.isInitialized()){
        handleSerial();
    }
    updateCubes();
    seq->updateSeq();
//    seq->run = run;
}
Exemplo n.º 4
0
void update(int value)
{
	updateAnimations();
	updatePointer();
	updatePlayer();
	updateBullet();
	updateCubes();
	updateExplosions();
	updateScore();

	// comunica cata cuburi mai sunt
	sprintf_s(_windowTitle, 39, "JakCube - %d cubes left", _evilCubes.size());
	_windowTitle[39] = NULL;
	glutSetWindowTitle(_windowTitle);

	glutPostRedisplay();
	glutTimerFunc(25, update, 0);
}