Synchronization and fps - mental confusion

Hi guys,
in my own demo I did insert one more sprite.

The first one was moved from the player, the other was moved from the cpu.

Logically the time of interaction between the two “player” is difference.

I read a WaitFrame function in the Sam Lantiga’s aliens demo:------------------------------------------------
void WaitFrame(void)
static Uint32 next_tick = 0;
Uint32 this_tick;

/* Wait for the next frame */
this_tick = SDL_GetTicks();
if ( this_tick < next_tick ) {
next_tick = this_tick + (1000/FRAMES_PER_SEC);




Okkey I think that this function make a delay if we have a cycle so
fast that it’s less than 1 second… right?

How can I move all my sprite in the same time?
How can I calculate the frame rate?


How can I move all my sprite in the same time?

Just make sure that you’re only delaying in the WaitFrame() function.

How can I calculate the frame rate?

In this case Sam uses a fixed frame rate, which is probably good
enough for most simple games. Try with #define’ing FRAMES_PER_SEC to
25 or something like that.
The downside to this solution is that when the computer is too slow to
draw 25 frames per second, the gameplay will simply run slower.

A better way to handle this is by doing something like described in
this short article: 9/27/06, Salvatore Di Fazio <salvatore.difazio at> wrote:

Rasmus Neckelmann