Lines Matching refs:light

62 /* Create a "light" -- a yellowish surface with variable alpha */
71 SDL_Surface *light;
79 light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 16,
86 light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 32,
88 if ( light == NULL ) {
89 fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError());
94 /* Fill with a light yellow-orange color */
95 skip = light->pitch-(light->w*light->format->BytesPerPixel);
97 buf = (Uint16 *)light->pixels;
99 buf = (Uint32 *)light->pixels;
102 pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0);
103 for ( y=0; y<light->h; ++y ) {
104 for ( x=0; x<light->w; ++x ) {
112 buf = (Uint16 *)light->pixels;
114 buf = (Uint32 *)light->pixels;
116 for ( y=0; y<light->h; ++y ) {
117 for ( x=0; x<light->w; ++x ) {
118 /* Slow distance formula (from center of light) */
119 xdist = x-(light->w/2);
120 ydist = y-(light->h/2);
144 SDL_SetAlpha(light, SDL_SRCALPHA|SDL_RLEACCEL, 0);
147 return(light);
153 void FlashLight(SDL_Surface *screen, SDL_Surface *light, int x, int y)
159 /* Easy, center light */
160 position.x = x-(light->w/2);
161 position.y = y-(light->h/2);
162 position.w = light->w;
163 position.h = light->h;
165 SDL_BlitSurface(light, NULL, screen, &position);
247 void MoveSprite(SDL_Surface *screen, SDL_Surface *light)
265 if ( light != NULL ) {
269 FlashLight(screen, light, x, y);
331 SDL_Surface *light;
403 /* Create the light */
404 light = CreateLight(82);
405 if ( light == NULL ) {
411 SDL_FreeSurface(light);
455 MoveSprite(screen, light);
535 SDL_FreeSurface(light);