Timer question (step seq)
in
Programming Questions
•
2 years ago
I've got this timer in draw():
- if (play == true) {
- int j;
- if (millis() - starttime < delaytime) {
- count_up = (millis() - starttime);
- //count_down = delaytime - count_up;
- steptimer = floor(10 / (delaytime / count_up));
- fill(0);
- textSize(12);
- text(steptimer, mouseX, mouseY);
- text(count_up, mouseX-30, mouseY-30);
- for (j = 0; j < rows; j++) {
- grid[steptimer][j].display(120);
- grid[steptimer][j].cellTrigger(steptimer,j);
- }
- } else {
- starttime = millis();
- j = 0;
- }
- }
The problem I'm having is that the for(j =0......) loop is being called every millisecond while the timer loop is alive. I really only want to update those values once for each time steptimer increments, otherwise those cells are being redrawn constantly until it does.
How do I do that? I'm totally lost on this after trying a million things..
I don't think its nessicary so I didn't paste the whole thing, but If you want to look at the full sketch it's here:
There's also a working embed/demo of the sketch with the minim stuff removed (everything else is the same) here:
1