   SDL Animation
  Hi.I'm new to SDL. Heres the code.//Include some files.#include "sdl.h"#include <stdlib.h>//Declare some variables.const int SCREEN_WIDTH=1280;const int SCREEN_HEIGHT=800;//Unit8Uint8 *keystates = SDL_GetKeyState( NULL );//displaySurface(Destination).SDL_Surface* displaySurface = NULL;//bitmapSurface(Source).SDL_Surface* bitmapSurface = NULL;//events.SDL_Event event;//Source rectangles and destination rectangles.SDL_Rect SrcRect,DstRect;//Call the main function.int main(int argc, char* argv[]){   //if sdl not initialized, report error if (SDL_Init(SDL_INIT_VIDEO) == -1){ //Report errorfprintf(stderr,"Could not initialize SDL!\n");//Exit outexit(1);}else{ //Report that SDL initialized properly!fprintf(stdout,"SDL initialized properly!\n");//When the user quits, it uses SDL_Quit.atexit(SDL_Quit);}//Create the displaySurface.displaySurface = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,0,SDL_FULLSCREEN);//If it doesn't work, then reportif (displaySurface == NULL){   //Report the error!fprintf(stderr,"Could not set up display surface!\n");//Exit out!exit(1);}SDL_WM_SetCaption("", NULL );//Load the bitmap.bitmapSurface=SDL_LoadBMP("Sprites\\Ball.bmp");//Set the color key for transparency in the bitmap.SDL_SetColorKey(bitmapSurface,SDL_SRCCOLORKEY,0);//If SDL could not load the bitmap, report it.if(bitmapSurface==NULL){//Report error! fprintf(stderr,"Could not load bitmap surface!\n");//Exit out!exit(1);}//Set the width of both rectangles which equals to the bitmap's width.SrcRect.w=DstRect.w=bitmapSurface->w;//Set the height of both rectangles which equals to the bitmap's height.SrcRect.h=DstRect.h=bitmapSurface->h;//Set the source rectangle position to 0,0.SrcRect.x=SrcRect.y=0;//The x position of the destination rectangle. DstRect.x=rand()%(SCREEN_WIDTH-DstRect.w);//The y position of the destination rectangle.DstRect.y=rand()%(SCREEN_HEIGHT-DstRect.h);//Blitting.SDL_BlitSurface(bitmapSurface,&SrcRect,displaySurface,&DstRect);//Update the displaySurface.SDL_UpdateRect(displaySurface,0,0,0,0); //An infinite loop.for(;;){   if((keystates[SDLK_RIGHT]) && (keystates[SDLK_UP]))   {   DstRect.x = DstRect.x + 1;   DstRect.y = DstRect.y - 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if((keystates[SDLK_RIGHT]) && (keystates[SDLK_DOWN]))   {   DstRect.x = DstRect.x + 1;   DstRect.y = DstRect.y + 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if((keystates[SDLK_LEFT]) && (keystates[SDLK_UP]))   {   DstRect.x = DstRect.x - 1;   DstRect.y = DstRect.y - 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if((keystates[SDLK_LEFT]) && (keystates[SDLK_DOWN]))   {   DstRect.x = DstRect.x - 1;   DstRect.y = DstRect.y + 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if( keystates[SDLK_RIGHT])   {   DstRect.x = DstRect.x + 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if(keystates[SDLK_LEFT])   {   DstRect.x = DstRect.x - 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if(keystates[SDLK_UP])   {   DstRect.y = DstRect.y - 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if(keystates[SDLK_DOWN])   {   DstRect.y = DstRect.y + 1;   SDL_UpdateRect(displaySurface,0,0,0,0);   }   else if(keystates[SDLK_ESCAPE])   {   exit(1);   }  //Blitting   SDL_BlitSurface(bitmapSurface,&SrcRect,displaySurface,&DstRect);    //Update the screen   //SDL_UpdateRect(displaySurface,0,0,0,0);   //If there is no eventsif(SDL_PollEvent(&event)==0){}else{    //Check if the event is SDL_QUIT.if(event.type==SDL_QUIT) break;}  }SDL_FreeSurface(bitmapSurface);//Report terminating normally.fprintf(stdout,"Terminating normally.\n");//Return(0);return(0);}When ever I move the ball around it leaves a mark. Could you help me on how to move the ball without leaving a trail?   
  You have to clear the screen using SDL_Rect before you draw again.See sig for examples.   ;  Thanks! I got it now! :)   