Original Post
Hi! i have 2 questions related to sdl , i hope you can help me. 1) There's a problem when im loading the images. Each time i move a sprite the screen fills with copies of the main sprite. First i'll show you the load_image function , which i found it at lazyfoo's site , but i've done some modifications. code: SDL_Surface *load_image( std::string filename ) { SDL_Surface* loadedImage = NULL; SDL_Surface* optimizedImage = NULL; SDL_Surface* final_img=NULL; loadedImage = SDL_LoadBMP( filename.c_str() ); if( loadedImage != NULL ) { optimizedImage = SDL_DisplayFormat( loadedImage ); SDL_FreeSurface( loadedImage ); } if( optimizedImage != NULL ) { //transparent //Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0, 0, 0 ); SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, optimizedImage->format->colorkey); final_img=SDL_DisplayFormat( optimizedImage ); SDL_FreeSurface(optimizedImage); } return final_img; } I think the problem is here: //Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0, 0, 0 ); SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY, optimizedImage->format->colorkey); return final_img; because , if i do this: Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0xFF, 0xFF, 0xFF ); SDL_SetColorKey( optimizedImage, SDL_RLEACCEL | SDL_SRCCOLORKEY,colorkey); Everything's working fine , BUT , im lacking of transparency!!...yes that means that the game looks WEIRD with the background of every image visible. Can you help me to fix the function?? 2) How can i get the "Top[Y] & left[X]" position of a surface , without adding temp variables while doing some action(moving for example)?? I found out(while searching on google) that calling ->GetX() & GetY() will work , but compiler says that such member doesnt exists.