Re: time loop

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sat, 22 Nov 1997, The Reaper wrote:

> Hi, does anyone know what I can put in my game's major loop, so that if a
> certain time hasn't passed, the game will wait?
>
> (Thus controlling the speed of the game through different situations and
> different computers)
>
>
yeah at the beginning for your main loop (somewhere) add something like
frameclock=time()

Then at the bottom do something like
while time()-frameclock< whatevertimeyouwannawait do
end while

when it gets to the while, if the amount of time you want hasn't already
passed it'll wait until it has then go on.  This just waits, it does no
processing.  If you want to process anything while you wait (like looking
at keys and doing something about them) stick the code between the while
and end while.


Michael

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu