Does anybody know how to create a countdown timer from 15 to 0 using a class?

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);
}
Tagged:

Answers

Sign In or Register to comment.