[SDL] SDL "Sprite" handling...
gordon+sdl at drogon.net
Wed Apr 18 07:18:33 PDT 2012
I'm looking to add some sprite handling to my little project - ie. a small
bitmap image that I can move over (on top of) the screen according to
I just want to make sure I'm not being too naive and not missing something
Looking at this:
it seems straightforward, however that program re-draws the entire screen
every frame. I want my sprites to "float" on-top of any background without
having to re-draw the background, so .... For each sprite, If I
blit the screen rectangle (same x,y,size as sprite) into a temp. buffer,
blit the sprite to the screen,
blit the screen temp. buffer back to the screen
lather rise, repeat with new sprite position and so on. Each sprite
needing a Surface to hold the sprite and another the same size to hold the
copy of the background.
I'm fairly sure that will work, but it will be doing a lot of memory moves
(even if rather small, say 20x20 pixels) and as long as I draw then /erase
them in the same order (or erase in reverse order) then the background
ought to stay untouched and sprites can happily move on-top of each other.
Although its will be doing a lot less memory moves than the example in
that website above!
I have seen SDL-Layer, but in its absence is the above OK, or am I
missing a trick?
More information about the SDL