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 & HelpPrograms › program help
Page Index Toggle Pages: 1
program help (Read 692 times)
program help
Apr 10th, 2010, 9:20am
 
just wondering if anyone could help me to make a small timer that will sit in the bottom left hand side of the screen that basically counts up in seconds until a certain action happens then it will re-set from the begging.

what i mean by this is, i have a small asteroid game, where asteriods constanly come at you and you have to shoot them, i want to add a timer so there is an aim to the game, to suvive as long as you can, then when your ship is hit the timer will restart.

Shocked
Re: program help
Reply #1 - Apr 10th, 2010, 9:36am
 
You'll want to use this:

http://processing.org/reference/millis_.html

Have a variable called timecheck or something like that.... set it
equal to millis() at the start. Then every frame your timer value is
(millis()-timecheck)/1000

Then you can have an if statement in draw() that checks if a "certain action" has occurred and if so, resets the time (i.e. timecheck
= millis() again).

Hope this helps.
Re: program help
Reply #2 - Apr 10th, 2010, 12:07pm
 
and as you called it "program help" wasnt easy to spot that it belongs in the program section Smiley ill move it
Re: program help
Reply #3 - Apr 11th, 2010, 5:14am
 
Giles wrote on Apr 10th, 2010, 9:36am:
You'll want to use this:

http://processing.org/reference/millis_.html

Have a variable called timecheck or something like that.... set it
equal to millis() at the start. Then every frame your timer value is
(millis()-timecheck)/1000

Then you can have an if statement in draw() that checks if a "certain action" has occurred and if so, resets the time (i.e. timecheck
= millis() again).

Hope this helps.



hey, thanks for your help, but im a total noob at processing, the link was helpful but im looking to make a small stopwatch kind of timer that can sit in the bottom left of the screen so the user can see the amount of time they have suvived, wheres the link makes a shiny square.


Re: program help
Reply #4 - Apr 11th, 2010, 5:44am
 
there are really a lot of posts dealing with this topic. just use the search.
this is one of them you could start with http://processing.org/discourse/yabb2/?num=1226560742
Page Index Toggle Pages: 1