Smooth car anim problem

Hi Guys,

Can somebody help me with this ?

Am doing a simple car race game using SDL in Linux.

Well the problem is in my animation loop the car image
is leaving traces even though am updating the screen
using SDL_BlitSurface() in the game loop :frowning:

Wat can b the possible problem ?

Hi

Make a third buffer that holds the “neutral” background, i. e. the one of the
track on which the car is driving that is “neutral” i. e. has nothing that
has to move on it.

Now, in each blit loop, to prevent “traces”, do like this:

  1. Blit the “master buffer” (i. e. the one that has no moving sprites on it)
    to the “temp buffer”. If the temp buffer already has cars on it, this will
    erase them.

  2. Blit all the cars and other moving sprites to the “temp buffer”, in the
    correct locations.

  3. Blit the temp buffer to the screen, or a rectangle around each spirte THAT
    IS LARGE ENOUGH TO CONTAIN IT, PLUS ANY MOVEMENT IT MADE IN THE MEANTIME.

  4. Move cars to new locations i. e. animating them.

  5. Repeat from (1)

Let me know if you still have trouble - I had exactly the same problem a while
ago.

Regards,–
Stefan Viljoen
F/EMS Dispatcher
Potchefstroom Public Safety Dept.
Republic of South Africa
http://home.intekom.com/rylan/

“We want you to be soldiers - deadly as long as you have one leg or one arm
and you are still alive.”

  • R. A. H. in Starship Troopers