As long as the gameplay is not frame-based, you don't really need to limit the frame rate. But if, for example, you move something a given distance each frame, then either stop doing that or limit the frame rate.
The trick to limiting the frame rate is to not just delay a fixed period of time after displaying each frame. What you need to do is record the time you start painting the frame, and then after the frame, delay as long as you want, but incorporate the time spent painting the frame.
Here's the basic idea (SDL code, but you get the idea):
Code:
Uint32 before, delay;
while(!game_ended()) {
before = SDL_GetTicks();
paint_frame();
delay = before + 33 - SDL_GetTicks();
if(delay > 0) SDL_Delay(delay);
}
SDL_GetTicks() is much like clock(): it returns the number of milliseconds the program has been executing for. But you can use any timing function, such as time().
33 is of course the frame rate. Make it whatever you like.
SDL_Delay() delays for the given number of milliseconds. If you can't find a function like that you could use something like this, though it would kill your CPU:
Code:
while(SDL_GetTicks() < before + 33);