I'm using SDL to create a 2D side-scrolling platformer, but I'm getting ghosting from the sprite. I'm not used to programming with graphics or SDL so excuse any stupid remarks I make.
Here's the issue:

The tutorial I'm following: http://gamedevgeek.com/tutorials/moving-sprites-with-sdl/
int main(int argc, char* argv[]) { SDL_Surface *screen, *temp, *sprite; int colorkey; SDL_Init(SDL_INIT_VIDEO); //Initialize SDL SDL_WM_SetCaption(WINDOW_TITLE, 0); //Window title screen = SDL_SetVideoMode(WINDOW_WIDTH, WINDOW_HEIGHT, 0, 0); //Create window frame SDL_EnableKeyRepeat(70, 70); //Keyboard Repeat temp = SDL_LoadBMP("sprite.bmp"); //Load the actual sprite sprite = SDL_DisplayFormat(temp); SDL_FreeSurface(temp); /* setup sprite colorkey and turn on RLE */ colorkey = SDL_MapRGB(screen->format, 160, 136, 128); //Make this RGB color transparent, so sprite isn't surrounded by a colored box SDL_SetColorKey(sprite, SDL_SRCCOLORKEY | SDL_RLEACCEL, colorkey); spriteRect.x = 150; //Initial X Position spriteRect.y = 150; //Initial Y Position /* set animation frame */ srcRect.x = 0; srcRect.y = 0; srcRect.w = SPRITE_SIZE; srcRect.h = SPRITE_SIZE; gameover = 0; /* message pump */ while (!gameover) { SDL_Event event; /* look for an event */ if (SDL_PollEvent(&event)) { HandleEvent(event); } /* collide with edges of screen */ if (spriteRect.x <= 0) spriteRect.x = 0; if (spriteRect.x >= WINDOW_WIDTH - SPRITE_SIZE) spriteRect.x = WINDOW_WIDTH - SPRITE_SIZE; if (spriteRect.y <= 0) spriteRect.y = 0; if (spriteRect.y >= WINDOW_HEIGHT - SPRITE_SIZE) spriteRect.y = WINDOW_HEIGHT - SPRITE_SIZE; SDL_BlitSurface(sprite, &srcRect, screen, &spriteRect); SDL_UpdateRect(screen, 0, 0, 0, 0); } /* clean up */ SDL_FreeSurface(sprite); SDL_Quit(); return 0; }
SDL_FillRect(screen, NULL, 0x000000);It would probably work differently if you were drawing a background. \$\endgroup\$