Code to execute only once every 0.5 seconds using ofGetElapsedTimef ()


#1

Please tell me how to write a loop that runs only 6 times within 3 seconds.
Run it once in 0.5 seconds.


#3

I would use a timer.
pseudo code:
setup()

startTime = ofGetElapsedTimeMillis();
countNr = 0;

update()

if (countNr < 6) {
	timer = ofGetElapsedTimeMillis() - startTime;
	if (timer >= 500) {
		countNr++;
		startTime = ofGetElapsedTimeMillis();

		// your code
	}
}