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.
Page Index Toggle Pages: 1
Timer (Read 1180 times)
Timer
Apr 7th, 2010, 5:09pm
 
Hi guys,
I need to add a timer for my game.
game duration is 3 minutes, so I want to start the game showing 3 min and keep deceasing it up to the end of the game

Any idea about that...

Thanks
Re: Timer
Reply #1 - Apr 7th, 2010, 8:59pm
 
Put this before the constructor:
int startTime= minutes()*60+seconds();
When you want to check time:
int endTime= minutes()*60+seconds();
if((endTime-startTime)==180)
{
...
}
Re: Timer
Reply #2 - Apr 8th, 2010, 4:42am
 
Thanks for your help.....

I actually tried but did not work

Can you give an example about that please

Thanks in advance

Re: Timer
Reply #3 - Apr 8th, 2010, 4:54am
 
Quote:
I actually tried but did not work

Can you give an example about that please

Advice: make a simple sketch trying to use what is given. Sometime attempts in larger sketches can fail for other reasons.
If it still doesn't work like you would, show us your attempt, so we can point out what is wrong.
Re: Timer
Reply #4 - Apr 8th, 2010, 5:26am
 
you probably want >= 180 in there - if it's checking less than once a second it might skip 180
Re: Timer
Reply #5 - Apr 8th, 2010, 5:38am
 
I tried to make in a very simple sketch but could not ....

I got the error that minute function is not exist !!!


can u explain the return value of min funtion ??

thanks
Re: Timer
Reply #6 - Apr 8th, 2010, 5:46am
 
http://processing.org/reference/minute_.html

http://processing.org/reference/min_.html
Page Index Toggle Pages: 1