Original Post
Hi all, I was enjoying myself with SDL, and now I have a little doubt. I want to blit on the background a Rect ( using an interesting code portion found on gamedev! ) then show the background again and blit another shape ( . . . ) ( check out the EXAMPLE 1 )
I absolutely don't want the situation shown on the EXAMPLE 2. So I was thinking how to refresh the background. Is that a nice solution? Do you know any other more efficient ways ( in terms of memory etc. etc. ) to solve this little problem? Thanks in advance! [Edited by - Clawer on March 2, 2007 2:50:46 PM]
I absolutely don't want the situation shown on the EXAMPLE 2. So I was thinking how to refresh the background. Is that a nice solution?
void render()
{
SDL_Rect rect;
rect.x = rand( ) % ( WIDTH );
rect.y = rand( ) % ( HEIGHT );
rect.w = rand( ) % ( WIDTH - rect.x );
rect.h = rand( ) % ( HEIGHT - rect.y );
// Let's fill a nice rect over the background!
SDL_FillRect( screen, ▭, SDL_MapRGB( screen->format, rand( ) % 256,
rand( ) % 256, rand( ) % 256 ) );
SDL_Flip( screen );
SDL_Delay(200);
// I'm blitting the background over the "old" Rect!
applySurface( 0, 0, image, screen );
}