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
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:
-
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. -
Blit all the cars and other moving sprites to the âtemp bufferâ, in the
correct locations. -
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. -
Move cars to new locations i. e. animating them.
-
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