We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want the timer to be a class and then call the class inside my main code.
This is just a timer I made in main code, I'm not sure if that will help make a class.
PFont font;
String time = "0:16";
int t;
int interval = 16;
void setup() {
size(300, 300);
font = createFont("AdobeHeitiStd-Regular", 30);
background(255);
fill(9);
}
void draw() {
background(255);
t = interval-int(millis()/1000);
time = nf(t, 3);
if (t == 0) {
println("GAME OVER");
interval +=16;
}
textFont(font);
text(time, width/2, height/2);
}
Answers
Previous posts: https://forum.processing.org/two/search?Search=countdown
Kf
You may also find useful:
...and, if you are interested in complex timers as opposed to simple ones, there are two timer libraries on the Processing Libraries page under Utilities: https://processing.org/reference/libraries/#utilities
When you create your new timer object, what arguments do you want to give it? The amount of time to run, or the time when it should stop...? What should your timer object do when the countdown stops?
For what it's worth, also check out my library - https://github.com/Lord-of-the-Galaxy/Timing-Utilities