//-------------------------------------------------------------- void testApp::update(){ int i; int numPoints =particles.size(); for( i=0; i<numPoints; ++i) { Particles *part = &particles[i]; part->update(1,1); } //particles[i].update(); mesh.particles = particles; mesh.update(); }
void onIdle() { int elapsedTime = glutGet(GLUT_ELAPSED_TIME) - lastUpdate; //elapsedTime = (int) (elapsedTime * 0.5f); //slow down //if (elapsedTime < 5) return; if (!paused) { // FPS COUNTER // fpsCounter[0] += elapsedTime; fpsCounter[1]++; if (fpsCounter[0] > 1000) { //system("cls"); cout << "FPS: " << 1000 / (fpsCounter[0] / fpsCounter[1]) << endl; fpsCounter[0] = fpsCounter[1] = 0; } // FPS COUNTER // cams.update(elapsedTime, &pacman); int pacmanDeathTime = maze.getPacmanDeathTime(); if (!pacmanDeathTime) { //pacman is alive pacmanIsAlive = 1; pacman.update(elapsedTime, &maze); maze.eatBallAt(pacman.getPosX(), pacman.getPosY()); ghosts.update(elapsedTime, pacman.getPosX(), pacman.getPosY(), &maze); } else { if (pacmanDeathTime + 6000 < glutGet(GLUT_ELAPSED_TIME)) { //pacman.onBirth(); pacman = Pacman(); ghosts = Ghosts(); maze.onPacmanBirth(); } else { if (pacmanIsAlive) { pacmanIsAlive = 0; particles.start(pacman.getPosX(), pacman.getPosY()); } particles.update(elapsedTime); } } glutPostRedisplay(); } lastUpdate = glutGet(GLUT_ELAPSED_TIME); }
void updateParticles(float dt){ glowParticles.update(dt); }