void World::update() { int timeElapsed_ms = calcTimeElapsed(); // Update all gameobjects std::list<GameObject *>::iterator it; for(it = objects.begin(); it != objects.end(); ) { // If update returns false, object should be deleted if((*it)->update(timeElapsed_ms) == false) { delete (*it); it = objects.erase(it); } else ++it; } }
inline unsigned long calcTimeLeft(unsigned long currentTs, unsigned long startTs, unsigned long duration) { return isTimePassed(currentTs, startTs, duration) ? 0 : duration - calcTimeElapsed(currentTs, startTs); }
inline bool isTimePassed(unsigned long currentTs, unsigned long startTs, unsigned long duration) { return calcTimeElapsed(currentTs, startTs) >= duration; }