Display a countdown (minutes'seconds ") which will stop when the minute and second will equal zero
in
Programming Questions
•
1 year ago
Hi,
I am trying to write a countdown that will be displayed and will stop when the minute and the second will be worth zero.
I had looked on the forum but I still can not solve the problem.
here is the code I've done but when I use WHILE loop so that the countdown stops when the minute and seconds worth
Zero, nothing appears on the screen.
the while loop is in comment
What can I do?
int time; //time
int minutes;
int seconds;
int timeLimit = 1; //1 min countdown
boolean stopped = false;
void setup(){
size(600,600); background(0);
PFont font = loadFont("NiagaraSolid-Reg-48.vlw");
textFont(font,55);
}
void draw() {
//while( !stopped){
countdown2();
//if( (seconds==0) && (minutes==0) ){ stopped = true;}
//}
}
void countdown2(){
time = timeLimit*60*1000 - millis();
minutes = seconds/60;
seconds =floor( time/1000 );
println((minutes) + "'" + (seconds) + "''" );
fill(0); rect(0,0,75,55); noFill();
fill(255); text((minutes) + "'" + (seconds) + "''", 5,45); noFill();
}
I am trying to write a countdown that will be displayed and will stop when the minute and the second will be worth zero.
I had looked on the forum but I still can not solve the problem.
here is the code I've done but when I use WHILE loop so that the countdown stops when the minute and seconds worth
Zero, nothing appears on the screen.
the while loop is in comment
What can I do?
int time; //time
int minutes;
int seconds;
int timeLimit = 1; //1 min countdown
boolean stopped = false;
void setup(){
size(600,600); background(0);
PFont font = loadFont("NiagaraSolid-Reg-48.vlw");
textFont(font,55);
}
void draw() {
//while( !stopped){
countdown2();
//if( (seconds==0) && (minutes==0) ){ stopped = true;}
//}
}
void countdown2(){
time = timeLimit*60*1000 - millis();
minutes = seconds/60;
seconds =floor( time/1000 );
println((minutes) + "'" + (seconds) + "''" );
fill(0); rect(0,0,75,55); noFill();
fill(255); text((minutes) + "'" + (seconds) + "''", 5,45); noFill();
}
1