One for the newbie pile

hi,

i’m new to using SDL and trying to get a grasp on some of the simpler
concepts before starting to hack away on a little ditty. i have created a
function to redraw a bitmap in a new location when the user clicks
on the location.

this works for me, but not how i expect it to:

void
DrawSprite(SDL_Surface *sprite, int x, int y)
{
SDL_Rect area;

SDL_FillRect(screen, NULL, background);

area.x = x;
area.y = y;
area.w = sprite->w;
area.h = sprite->h;

SDL_BlitSurface(sprite, NULL, screen, &area);

SDL_Flip(screen);
}

this is being called from my event filter, and just passes the same
surface each time, with new coordinates, thereby emulating ‘movement’ of
the image. the problem i’m seeing is that the old location of the surface
is not refreshed/the background doesn’t fill in over the old bitmap.

BUT, if i put a call to SDL_Flip(screen) in just after SDL_FillRect(), i
get the desired behavior (the old location is filled in with the
background color).

can anyone tell my why that is/what i’m missing? is there something
glaringly obvious i’m overlooking?

thanks!
-eric

BUT, if i put a call to SDL_Flip(screen) in just after SDL_FillRect(), i
get the desired behavior (the old location is filled in with the
background color).

Hrm… it should work, even if you didn’t set the doublebuffer flag when
you created the ‘screen’ surface (window).

-bill!