PDA

Click to See Complete Forum and Search --> : Game Loops


DarkMoose
Oct 3rd, 2000, 02:11 PM
I've been using Game Loops for my programs - the Do Until loops that run endlessly, moving stuff and BitBlting sprites forever and ever til the end of the program - you know the stuff. I send the games to people over the internet, and they say the game is running waaay too fast. It runs fine for me, but my computer is old and runs slower. So, how can I keep the game loop running at a rate that makes everyone happy!?

HarryW
Oct 3rd, 2000, 02:41 PM
Use the GetTickCount API (declaration of it will be in API viewer, I can't remember it off the top of my head). It returns the number of milliseconds since system startup. Use a global variable for the tick count last time through your loop and each subsequent time through the loop, check if the tickcount is a certain amount more than it was last time you did your loop stuff. So, for 50 frames per second, go through the loop every 20 milliseconds. Get the idea?

DarkMoose
Oct 3rd, 2000, 05:09 PM
So GetTickCount gets a number of milliseconds that is uneffected by computer speed and should be the same every time the program is run no matter how fast the loop is running?? That sounds good, I think that will solve my problemz, thankz.

HarryW
Oct 3rd, 2000, 05:27 PM
Yep, that's about it. No problem ;)

Fox
Oct 4th, 2000, 02:39 PM
...but remember: you may slow down your game by waiting for 50ms each loop, but you won't speed it up if the computer's too slow ;)

DarkMoose
Oct 4th, 2000, 03:23 PM
LOL, well I don't know anyone with a really slow computer. Except maybe me...maybe that's why I'm having problems in the first place... . o O ( Stewpid, cheap computer ) **kicks the CPU and sees Window crash again**

NOOOOOOO NOT AGAIN!!!!