comparison test/testalpha.c @ 2267:c785543d1843

Okay, still some bugs, but everything builds again...
author Sam Lantinga <slouken@libsdl.org>
date Sat, 18 Aug 2007 05:39:09 +0000
parents c121d94672cb
children 44e49d3fa6cf
comparison
equal deleted inserted replaced
2266:e61ad15a205f 2267:c785543d1843
251 251
252 void 252 void
253 MoveSprite(SDL_Surface * screen, SDL_Surface * light) 253 MoveSprite(SDL_Surface * screen, SDL_Surface * light)
254 { 254 {
255 SDL_Rect updates[2]; 255 SDL_Rect updates[2];
256 int alpha; 256 Uint8 alpha;
257 257
258 /* Erase the sprite if it was visible */ 258 /* Erase the sprite if it was visible */
259 if (sprite_visible) { 259 if (sprite_visible) {
260 updates[0] = position; 260 updates[0] = position;
261 SDL_BlitSurface(backing, NULL, screen, &updates[0]); 261 SDL_BlitSurface(backing, NULL, screen, &updates[0]);
288 y_vel = -y_vel; 288 y_vel = -y_vel;
289 position.y += y_vel; 289 position.y += y_vel;
290 } 290 }
291 291
292 /* Update transparency (fade in and out) */ 292 /* Update transparency (fade in and out) */
293 alpha = sprite->format->alpha; 293 SDL_GetSurfaceAlphaMod(sprite, &alpha);
294 if ((alpha + alpha_vel) < 0) { 294 if (((int) alpha + alpha_vel) < 0) {
295 alpha_vel = -alpha_vel; 295 alpha_vel = -alpha_vel;
296 } else if ((alpha + alpha_vel) > 255) { 296 } else if (((int) alpha + alpha_vel) > 255) {
297 alpha_vel = -alpha_vel; 297 alpha_vel = -alpha_vel;
298 } 298 }
299 SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel)); 299 SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8) (alpha + alpha_vel));
300 300
301 /* Save the area behind the sprite */ 301 /* Save the area behind the sprite */