First of all happy new year to everyone. I hope someone can help me with this:
Basickly I have a draw function, a transparent function and a function for loading entityes. My problem is that whenever I try to apply my transparent function on an entity it just keeps its color, nothing changes. Here are the functions :
//Draw Function
bool GameSurface::OnDraw(SDL_Surface* Surf_Dest, SDL_Surface* Surf_Src, int X, int Y) {
if(Surf_Dest == NULL || Surf_Src == NULL) {
return false;
}
SDL_Rect DestR;
DestR.x = X;
DestR.y = Y;
SDL_BlitSurface(Surf_Src, NULL, Surf_Dest, &DestR);
}
//Load Function
SDL_Surface* GameSurface::OnLoad(std::string filename) {
SDL_Surface* Surf_Temp = NULL;
SDL_Surface* Surf_Return = NULL;
if((Surf_Temp = IMG_Load(filename.c_str())) == NULL) {
return NULL;
}
Surf_Return = SDL_DisplayFormatAlpha(Surf_Temp);
SDL_FreeSurface(Surf_Temp);
return Surf_Return;
}
//Transparent function
bool GameSurface::Transparent(SDL_Surface* Surf_Dest, int R, int G, int B)
{
if(Surf_Dest == NULL) return true;
SDL_SetColorKey(Surf_Dest, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(Surf_Dest->format, R, G, B));
return true;
}
//Entity load function
bool Entity::OnLoad(std::string filename, int Widght, int Height, int MaxFrames){
if((Surf_Entity = GameSurface::OnLoad(filename.c_str())) == NULL) return false;
GameSurface::Transparent(Surf_Entity, 255, 0, 255);
this->Widght = Widght;
this->Height = Height;
Anim_Control.MaxFrames = MaxFrames;
return true;
}
Thanks in advance ! PS: I know there isnt much commenting going on but if needed I will provide some