Hi, I'm in the process of writing my own FPS in C++ and I had a general question about game programming. Up until this week, I was developing the game on a computer with a low-end graphics card and everything was working just fine.

This week, I've changed my development to a newer computer with a brand new graphics card. When I ran my game, everything was moving WAY too fast. I think I know what caused this. Since my current computer is so much faster, the game loop runs more quickly which in turn causes the units to move more often (faster).

What can I do to prevent this? How do I make a game run at the same speed on a low-end computer as a high-end computer?

Thanks in advance.

Recommended Answers

All 3 Replies

This week, I've changed my development to a newer computer with a brand new graphics card. When I ran my game, everything was moving WAY too fast. I think I know what caused this. Since my current computer is so much faster, the game loop runs more quickly which in turn causes the units to move more often (faster).

That's the most likely reason--you'll see this happen with a lot of older games as well.

What can I do to prevent this? How do I make a game run at the same speed on a low-end computer as a high-end computer?

You need some sort of timer to let you know how long it's been since the last time through your game loop. In this case, you'll want to wait until a certain amount of time has passed (exactly how much is up to you--how fast do you want it to go?) before you update your game objects.

Okay, I'll look into making a timer for moving units within the game loop. Would it also work to change the max FPS of the game? Or should I not do that, and just stick with the timer?

Thanks.

Would it also work to change the max FPS of the game? Or should I not do that, and just stick with the timer?

All else being equal, I'd recommend keeping game time independent of framerate. Limiting the maximum frames/second can keep it from running too fast, but slower machines that can't achieve that limit will appear to be running in slow motion (the inverse of your current issue). If you track time separately, the framerate may drop on some systems, but the action will remain consistent.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.