Controlling speed based on machine performance
 
 
WoolyMammoth  
(1/12/00 2:18:14 pm)

How do I make it so that my DirectX7 DirectDraw game runs at the same speed on all computers? Thanks for all the help so far.



 
black eyez  
(1/12/00 7:25:46 pm)

What you can use is GetTickCount in your main game loop.. Have it so that it will only allow the loop to execute if a certain amount of time has passed. This makes the animation the same speed on all computers as long as they can keep up to the minimum you set. 

David



 
WoolyMammoth  
(1/12/00 8:30:48 pm)

Excellent... thanks



 
Eric Coleman  
(1/13/00 11:42:48 am)

This is what I do to insure a constant speed of gameplay on different computers. 
I make the frame to display a function of the tickcount. 

For example and for simplicity of the example, 
assume you want 10 frames per second, which means you'll want to draw a frame every 100 tickcounts. (1000 tickcounts = 1 second). 
Then the program would draw frame 0 between 0 and 99 tickcounts, 
frame 1 between 100 and 199 tickcounts, 
frame 2 between 200 and 299 tickcounts, 
or however you want to set it up. 

If the program gets a tickcount of 134, it draws frame 1, 
then the next time a tickcount is read, and it happens to be 429, then frame 4 is drawn, skipping frames 2 and 3. This frame skipping helps to insure that the game play happens at the same speed. 

You can use this idea to somewhat sychronize internet applications. Granted this method I'm about to explain won't work for a doom type game or something with really fast action like that. It would work for a RPG for example. 

If person A is acting as a server, then person B which is a client, pings the server and adjusts their tickcount based on that reply. Example, person B pings person A and gets a 829 ms delay. To somewhat synchronize them, person B adjusts his tickcount by adding 829. So if his tickcount is 384, he adds 829 to get 1213. Frame 12 would then be drawn instead of frame 3. 

I hope that helps, 

Eric



 
WoolyMammoth  
(1/13/00 4:01:21 pm)

Thanks everyone