Multiple Randomized Timers

I modified the example ‘SimpleTimer’ to automatically update. What I would like to do, and am unable, is to have multiple timers update with different random start times. I tried to add another class with a second timer contained within it and still no luck. Any timers I add update with the same random numbers. Here’s the code I am using as a starting point with one timer only. Obviously, I’m just getting started — this is my first project. Any insight is greatly appreciated. Thank you!

class testApp : public ofBaseApp{


void setup();
void update();
void draw();

int startTime;
int endTime;

bool bTimerReached;


#include “testApp.h”

void testApp::setup(){


void testApp::update(){

if (bTimerReached) {
bTimerReached = false;
startTime = ofGetElapsedTimeMillis();
endTime = (int)ofRandom(1000, 10000);


void testApp::draw(){

int timer = ofGetElapsedTimeMillis() - startTime;

if(timer >= endTime && !bTimerReached) {
bTimerReached = true;

string info = “FPS: “+ofToString(ofGetFrameRate())+”\n”;
info += “Start Time: “+ofToString(startTime)+”\n”;
info += “End Time: “+ofToString(endTime/1000)+” seconds\n”;
info += “Timer: “+ofToString(timer/1000)+” seconds\n”;
ofDrawBitmapString(info, 20, 20);

you should setup different startTime and endTime variables for every timer; the best thing would probably be to create a timer class and declare multiple instancies of it.

Thank you, naus3a. I made a timer class and it worked.