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.
IndexDiscussionExhibition › Counting Down
Page Index Toggle Pages: 1
Counting Down (Read 1100 times)
Counting Down
Feb 7th, 2008, 11:02pm
 
Hi there.  I'm not sure if this is the right forum for this or not, but I just started using processing and am interested in messing around with the idea of counting up and counting down.

Is there a simple way that I can't find to do the following:

Display a number, let's say 1500.

At timed intervals, like 1 second, the display counts down to 1499.  I can't figure a way out without looping it somehow.

Any help whatsoever would be greatly appreciated!

-andrew
Re: Counting Down
Reply #1 - Feb 8th, 2008, 1:30am
 
Code:

int start;
int period;
void setup()
{
//normal setup stuff
start=millis();
period=1500;
}

void draw()
{
int timeleft=period=(millis()-start)/1000;
println(timeleft);
if(timeleft<=0)
{
//countdown is 0. (or less)
}
}
Page Index Toggle Pages: 1