Well! I personally would use my own timer handling in such a case. Quite easy to implement…
Internally processing works with long as it uses System.currentTimeMillis()-starttime to calculate the return value for millis(), but unfortunately casting to int for return value imo due to follow a rule to keep the datatype usage simple.
Indeed. It’s just that I’ve been using millis() for years, even for works running for a very long time, and now I’m wondering what magic made them work without a glitch for so long.
in the most common usage the impact will be quite low… see below.
Cheers
— mnse
PS: Nevertheless, I personally wouldn’t use millis(), if I would expect the process should run stable and longer then 24d.
final int deltaTimeMS = 1000;
int nextStepMS;
long current;
void setup() {
size(500, 500);
noStroke();
current = Integer.MAX_VALUE - 20000L;
nextStepMS = (int)current;
}
int next() {
current+=100L;
return (int)current;
}
void draw() {
background(0);
int t = next();
// Most common approach, less impact as the logic still works as both flip signs
if (t >= nextStepMS) {
println("do somthing: " + t);
nextStepMS = t + deltaTimeMS;
}
fill(0, 255, 0);
// another approach with modulus will break because of sign flip
arc(width*.25, height/2, 100, 100, 0, radians(floor(t/100.) % 360));
fill(255, 0, 0);
// same approach but with absolute modulus, will flip rotation direction
arc(width*.75, height/2, 100, 100, 0, radians(abs(floor(t/100.)) % 360));
}