How to display a countdown?

edited February 2017 in Questions about Code

I am currently trying to display a countdown, where when the countdown is finished, the game will start. Here is my code

void draw() {
  background(255);
  textSize(14);
  fill(0);
  textAlign(RIGHT);
  text("Use the arrow keys to move", width, height-20);
  text("Press pause to take a break", width, height-5);
  if (alive && Countdown()) {
      obstacles();
      interactions();
    } else { 
      restart();
    }
  }


boolean Countdown() {
  textAlign(CENTER);
  text(countdown, width/2, 50);
  countdown -= 1;
  if (countdown>0) return false;
  else return true;
}
Tagged:
Sign In or Register to comment.