We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › counting down from 2 minutes
Page Index Toggle Pages: 1
counting down from 2 minutes (Read 257 times)
counting down from 2 minutes
Mar 9th, 2009, 7:53pm
 
I know this should probably be really easy, but can't seem to figure it out. I would like to display a timer or a stop watch type display and show it counting down from the 2 minute mark. showing minutes/seconds/milliseconds.  Any help is appreciated.
Re: counting down from 2 minutes
Reply #1 - Mar 9th, 2009, 8:56pm
 
int target = 2000;
void draw()
{
 int time = millis();
 int m = target-time;
 println("millis:"+m);
 println("hundreds:"+m/10f);
 println("tens:"+m/100f);
 println("seconds:"+m/1000f);
 println(m);
 if(m <= 0){
   println("done");
   exit();
 }
}
Re: counting down from 2 minutes
Reply #2 - Mar 10th, 2009, 4:05am
 
Why doesn't this work?

Why doesn't this work?

PFont font;
void setup(){
 size(500,500);
 smooth();
font = loadFont("serif.vlw");  
}

void draw(){
 background(255);
 
 int sec = second();
 int minutes = minute();
 int hours = hour();
 //println (hours + ":" + minutes + ":"+sec);

text(sec,250,250);
text(minutes,250,250);
text(hours,250,250);
}
Re: counting down from 2 minutes
Reply #3 - Mar 10th, 2009, 5:31am
 
It looks like you forgot to call textFont(font);
Page Index Toggle Pages: 1