PDA

Click to See Complete Forum and Search --> : Timing


Sastraxi
Feb 22nd, 2001, 06:21 PM
For my Nibbles Revenge, I have used 2 types of timing:

1. Do...Loop
2. Timer1_Timer

Method 2 is too slow, while Method 1 will be different for everycomputer and the time needs to be changed in between (eg - 20 frames a second start-game to 35 fps mid-game, etc.) The frame rates are strictly for timing purposes.

I need a timing type that is faster than do...loop because I KNOW my computer can go faster, and one that is controlled. ANYBODY???

HarryW
Feb 22nd, 2001, 10:08 PM
Use GetTickCount, and loop until 30 ms (for 33 fps) or however long you want has passed. It's really very easy.

Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long


It returns the number of milliseconds since system startup. While that may seem rather useless, you can take values and use the difference as a measure of how much time has elapsed.

DarkJedi9
Feb 22nd, 2001, 10:16 PM
Harry, i'm just guessing but that might be what he means by do...loop. just my guess, though

HarryW
Feb 22nd, 2001, 10:47 PM
Well he said it "will be different for every computer", which it wouldn't be if he was using GetTickCount.

DarkJedi9
Feb 23rd, 2001, 09:11 AM
Good point. I'd forgotten about that.

On a somewhat related note, I just wrote a game and its timing method is a do loop with a sleep statement, which should be consistent for every CPU. You can check it out in the Games and Graphics forum in the post titled "check this out".

DarkJedi9
Feb 23rd, 2001, 09:19 AM
This should be the link:
http://forums.vb-world.net/showthread.php?s=&threadid=56672