Constant framerate code?

Hi people :slight_smile:

I’ve been making a game in SDL and OpenGL but I’m having some problems with
the framerate… is there a way I can make the game run at, for example,
30fps on any machine? (smoothly if on fast PC and skipping frames if in slow
PC?)… I know the theory behind, but I’ve been googling around and such and
I haven’t found any code to adapt to my game in any way :/.

Any help is appreciated! :smiley:

  • DARKGuy

LazyFoo and Sol’s tutorials on the SDL site helped me out alot but for most
of my progs I adapted my own code for it.
Essentially, I just have a text file with the number of FPS (physical
iteration per second) in my main code. Use the SDL_ticks function in an
equation to determine how many frames have passed. Then, the user can config
it manually, or add something into your program at startup that if the
physical FPS hasn’t been set, to pop up a config dialog that configures it
automatically through a series of loops.

I’ve had this problem getting a program to work on one OS or another but the
actual speed(CPU/RAM) has really been negligent in the equation considering
the faster the computer runs, the longer it’s going to stall to run the next
iteration/loop. My actual framerate code was adapted from the Open Zelda
timedelta() function. Hope this helps some.