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 / How to judge passage of time?

Author
Message
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 26th Feb 2003 23:25
What is the best way to measure time (i.e. to create a delay in a real-time game). I want to judge it in actual seconds, not frames.
Any suggestions are appreciated.
QuothTheRaven
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: United States
Posted: 26th Feb 2003 23:40
the command wait works in seconds

wait 100 is one second. Or maybe its wait 1000. No, its wait 100.

you could grab the screen fps and use that to determine how long you need to delay...

Darken the skies, we are God.
Shadow
22
Years of Service
User Offline
Joined: 17th Oct 2002
Location: In the shadows
Posted: 26th Feb 2003 23:52
Wait is no good as it halts the program.
I was thinking something like:



To add a "K" every 0.25 seconds (just as example - I don't actually need a program to add K's).
PiratSS
22
Years of Service
User Offline
Joined: 18th Oct 2002
Location:
Posted: 27th Feb 2003 00:17
wait 1000(each 1 is milisecond) would give u 1 second wait :0


Toughest line of codecol$=asc(left(Pcol$)),1+str$(rev)+chr(80)+left(right(mid(name$),1),1)
The Darthster
22
Years of Service
User Offline
Joined: 25th Sep 2002
Location: United Kingdom
Posted: 27th Feb 2003 00:57
I think timer() is your best bet.

t=timer()
while t+0.5>timer():wend

Ahhh, that takes me back.

Alternately,

do
...
time#=timer()-t#
distance = speed x time# (etc.)
t#=timer()

time2#=timer()-s#
if time2#>=0.25
print "k"
s#=timer()
endif

...
loop

Just some examples, on calculating the time passed in a frame, and also calling events every specific time interval, although you will have to check the units of timer(), 0.25 might mean 0.25s or 0.00025s, I can never remember.

Once I was but the learner,
now, I am the Master.
BoB Vila
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United States
Posted: 27th Feb 2003 21:53
The timer would definatly the a good way to go, if you wan't to calculate actual time. But if you want a timer that is relative to your other ingame calculations you can just use a float that you increment by something like .00000001 every time you game loops past the sync function. That way you can use it as a count down time.

Login to post a reply

Server time is: 2024-11-24 04:51:15
Your offset time is: 2024-11-24 04:51:15