-
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???
-
Use GetTickCount, and loop until 30 ms (for 33 fps) or however long you want has passed. It's really very easy.
Code:
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.
-
Harry, i'm just guessing but that might be what he means by do...loop. just my guess, though
-
Well he said it "will be different for every computer", which it wouldn't be if he was using GetTickCount.
-
touché!
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".
-