void GamePlay::update(float time) { //! Decrease the time bonus score over time if(inPlay == true && timeScore != 0) { timeScore = timeScore - time; } //!npc update functions std::vector<Npc>::iterator updateit; for(updateit = npc.begin(); updateit != npc.end(); ++updateit) { updateit->animate(); //!< animate the npc updateit->integrate(time); //!< integrate the npc } std::vector<Npc>::iterator powerUpdate; for(powerUpdate = powerUps.begin(); powerUpdate != powerUps.end(); ++powerUpdate) { powerUpdate->animate(); powerUpdate->integrate(time); } //!integrate / animate player object player.animate(); player.integrate(time); if(inPlay == true)player.handleInput(); //!< if game is inplay then the player can move collisionHandling();//!< collision handling function call screenMovement(player, mainView, backgroundSprite); //!< screen movement function call //! update the score messages with the actual score for(int i=0; i<5; ++i) { message[i].setString(StringMessage[i]); StringMessage[Lives] = "Lives: "+std::to_string(lives); StringMessage[Score] = "Score: " +std::to_string(score); StringMessage[TimeScore] = "Time-Score: "+ std::to_string(timeScore); StringMessage[FinalScore] = "Press R to play again! Final Score: "+ std::to_string(finalScore); } //! if player is dead, erase all npc's and run the init function again if(lives ==0) { backgroundMusic.stop(); gameOverSound.play(); _sleep(3000); npc.erase (npc.begin(),npc.end()); init(); } //! level finish function call (checks if level has been complete) levelFinish(time); }
void ActionManager::update(u32 time){ currentTime = time; //update current time if(inGame){ if(enemyGenerator->isReady(time)) //if it is time to generate new enemies enemyGenerator->generateWave(ENEMYWAVE_EMPTY, time); //just do it collisionHandling(); checkForCapture(); } else { gameOverDelay(); } removeInvisibleProjectiles(); }