Втавил Palette, визуальный эффект отсутствует.
| Код | SDL_RWops *rwop = SDL_RWFromFile("images/bg.png", "rb"); SDL_Surface *back = IMG_LoadPNG_RW(rwop);
SDL_Surface *image=SDL_LoadBMP("images/snake.bmp"); SDL_Surface *screen=SDL_SetVideoMode(800,600,8,SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_HWPALETTE);
void initsystem() { if ( SDL_Init(SDL_INIT_TIMER|SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ){ printf("Unable to init SDL: %s\n", SDL_GetError()); exit(1); } atexit(SDL_Quit); if (!back || !image || !screen ){ printf("error while loading images, check SnakeDir/bmp\n"); exit(1); }
SDL_WM_SetCaption("Snake from Powerfox","Snake"); SDL_WM_SetIcon(SDL_LoadBMP("images/icon.bmp"), NULL);
if ( screen == NULL ){ printf("Unable to set 800x600 video: %s\n", SDL_GetError()); exit(1); }
SDL_Color colors[256]; int i; /* Fill colors with color information */ for(i=0;i<256;i++){ colors[i].r=i; colors[i].g=i; colors[i].b=i; } DrawBG(); DrawIMG(image, 180, 0); DrawIMG(image, 120, 0); DrawIMG(image, 60, 0); SDL_SetPalette(image, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256); SDL_Flip(screen); makefood(); initsound(); //image->format=".bmp"; int r = 249; int g=0; int b=0; SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format,r,g,b)); }
| |