I have tried to move an image by saving background and blitting
image, restoring background and so on. But I’m missing something
here and this doesn’t work, please look at this code:
area.w=sp->w;
area.h=sp->h,
area.x=1;
area.y=1;
//Save background area
SDL_BlitSurface(screen, &area, saved, &area);
// Then put image
SDL_BlitSurface(sp, NULL, screen, &area);
// And update screen area
SDL_UpdateRects(screen,1,&area);
for (i=1;i<=200;i++) { //Move sprite
//First, restore saved area
SDL_BlitSurface(saved, NULL, screen, &area);
SDL_UpdateRects(screen,1,&area);
//Increment x&y
area.x++;
area.y++;
SDL_BlitSurface(screen, &area, saved, &area);
SDL_BlitSurface(sp, NULL, screen, &area);
SDL_UpdateRects(screen,1,&area);
}
This leave a black square and the trasnparent part of the image
gets mixed with the backgound. What’s the problem?–
Roger D. Vargas