Blitted images stay on screen

Hey all,
Kinda newbie question, but I have my main() function pass the main
SDL_Surface * screen to an object to blit the object surface to its
destination (the main screen). but, when I move the object, the original
one is continually drawn beneath the new one…its not erasing the old
images.
Am i missing something about passing surfaces into a function or a class?
I have the screen being a global, but the classes cannot access it if I
don’t pass it in. Also, the surfaces in the classes are public
members…should they not be so they are destroyed every function call? I’m
confused! Thanks for your help!

Mike

Hi Michael,

You need to image the screen as an image in a paint program.
Your blitting of the object is like painting with a brush into the image.

If you want that the background stays the same (is not destroyed by the
moving bject in front) then you need to redraw the background before
blitting your sprite.

Example code:

screen=open_screen
background=load_image
sprite=load_image

loop{
blit_background on screen
blit sprite on screen
}

Cheers
Gunnar

Michael Balogh wrote:> Hey all,

Kinda newbie question, but I have my main() function pass the main
SDL_Surface * screen to an object to blit the object surface to its
destination (the main screen). but, when I move the object, the original
one is continually drawn beneath the new one…its not erasing the old
images.
Am i missing something about passing surfaces into a function or a class?
I have the screen being a global, but the classes cannot access it if I
don’t pass it in. Also, the surfaces in the classes are public
members…should they not be so they are destroyed every function call? I’m
confused! Thanks for your help!

Mike


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl