@jacob1342 wrote:
Hi, I want to make loop that will color circles but one circle at a time and every 2 seconds. So far Im using delay method with while loop but it makes my project freeze at the beginning and after some time it already shows all circles with changed color.
This is my draw method
void ofApp::draw(){ int i = 0; while (i < vertices.size()) { for (int j = 0; j < visitedToDraw.size(); j++) { if (vertices[i].getId() == std::to_string(visitedToDraw[j])) { vertices[i].drawBFS(); delay(1); } } i++; } }
Here is my delay method
void ofApp::delay(int number_of_seconds) { // Converting time into milli_seconds int milli_seconds = 1000 * number_of_seconds; // Stroing start time clock_t start_time = clock(); // looping till required time is not acheived while (clock() < start_time + milli_seconds) ; }
Posts: 3
Participants: 2