Need constant frame rate on different computers

Started by
3 comments, last by Dave Hunt 18 years, 9 months ago
I was looking around for a way to make my game's frame rate the same on different computers. What I don't like is that every tutorial I've found insists that you multiply everything in your game by some speed factor. When I used Allegro it was brilliant. Somehow (using an interrupt, I believe) it made it so I didn't need to change anything else. I just designed the game for 60FPS and it did the rest using its timer. Is there any timer library or code I can use that does the same without Allegro (I'm using Irrlicht now for 3D)? Or, as an alternatvie, is Allegro compatible with Irrlicht? Can I use both? And if so, is there a way to import only the timer into my EXE? (I remember the filesize got pretty big otherwise.) Thanks.
Advertisement
If you do your timing based on the elapsed time per frame, then you don't have to change anything when you move from computer to computer. First, determine how fast you want an object to move in pixels per second. Then, each frame, move the object by that amount times the elapsed time. With this method, no matter how fast or slow the machine is, the object will always move the same number of pixels per second.
Quote:Original post by Dave Hunt
If you do your timing based on the elapsed time per frame, then you don't have to change anything when you move from computer to computer. First, determine how fast you want an object to move in pixels per second. Then, each frame, move the object by that amount times the elapsed time. With this method, no matter how fast or slow the machine is, the object will always move the same number of pixels per second.

Actually, a better way would be to use a Fixed Timestep.
And there's the article that orignally appeared on flipcode
Quote:Original post by bytecoder
Actually, a better way would be to use a Fixed Timestep.


I would say different, not necessarily better. Certainly a good alternative, though.

This topic is closed to new replies.

Advertisement