Old school platorm gameA scrolling, platform-jumping, key-collecting, ancient pyramid exploring game, vaguely in the style of similar games for the Commodore+4. The game is intended to show young people all the cool games they missed.
License: free
Requirements: SDL, SDL_mixer
| Sound: | Play in X: | Play in Console: | Multiplayer: | Network Play: | 3D Acceleration: | Source Available: |
|---|---|---|---|---|---|---|
| yes | yes | no | no | no | yes | yes |
Submitted by gabortorok on 2003-01-13.

If you're not too bothered about using Frame Based Movement (only a bad idea if you're using 3D or a network game) then you could always use the "Sleep period" method.
At the beginning of each frame use SDL_GetTicks() and store the value into a long. At the end of the frame loop compare the current SDL_GetTicks() with the value you stored at the beginning of the frame. If enough time has passed, then allow the game to continue. Otherwise go into a loop until enough time has passed.
For example,
long ticks; while (true) { ticks = SDL_GetTicks(); // all your drawing and game stuff goes here while (SDL_GetTicks() < (ticks + 16)){} }The above may look crude, but it will prevent the game from running any faster than 60 frames per second (or there abouts).
td2=SDL_GetTicks(); dt=((float)(td2-td))*0.1; // 10*dt = 1 Frame td=td2;
Now multiply your object offset with dt.
After 1 second we have traveled 100 pixels. e.g. 50 Hz would give a dt of 2 (20msec per frame), and 120 Hz would give a dt of 0.8333 (8.333 msec per frame), or without vsync 333 FPS would give a dt of 0.3.