Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / time delay

Author
Message
GameMaker Jason
21
Years of Service
User Offline
Joined: 22nd Nov 2003
Location: UK
Posted: 27th Jun 2004 11:57
how do i make my programs include a time delay eg wait 5 mins

Damokles
21
Years of Service
User Offline
Joined: 28th May 2003
Location: Belgium
Posted: 27th Jun 2004 14:14
here for 5 seconds :

Timestart = TIMER()
REPEAT
UNTIL TIMER() > Timestart + 5000

- Mind the gap -
Mentor
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: United Kingdom
Posted: 27th Jun 2004 14:45 Edited at: 27th Jun 2004 14:47
or more practicaly, just get the current time

t=timer()

so now t holds the time in millisecs

add the delay, for 5 minutes you need 300 seconds times the number of millisecs eg:-

t=t+(300*1000)

this value is 300,000 milliseconds larger than the timer value was when you checked it, thats 5 minutes until the timer counts up to this value, so in your main loop do this

if timer()>=t
Explode_Bomb()
endif

note that you check for the timer being equal or greater than the calculated value, if your program was doing a lot in the main loop then it may only repeat every 50 millisecs (20fps), so you may get the case where on the last loop the timer was 10 millisecs smaller than the calculated value, and on the next loop its 40 millisecs larger, so it never actualy equals the value when the check is done, so you test for it being equal or larger just in case it overuns the value, hope thats some help.

Mentor.

PC1: P4 hyperthreading 3ghz, 1gig mem, 2x160gig hd`s, Nvidia FX5900 gfx, 6 way surround sound, PC2: AMD 1.2ghz, 512mb ram, FX5200 ultra gfx, stereo 16 bit soundblaster.

Login to post a reply

Server time is: 2024-11-26 22:35:14
Your offset time is: 2024-11-26 22:35:14