From ace244678b2cfd6c705ec9180eb0e142e466786a Mon Sep 17 00:00:00 2001 From: Rob Pearce Date: Thu, 26 Mar 2009 23:38:16 +0000 Subject: [PATCH] - Fixed graphical glitch with angry doom cloud - Fixed bug where two doom clouds could appear --- rc.c | 19 ++++++++++++++++--- shared.c | 34 +++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/rc.c b/rc.c index 791a4dc..105c1ee 100644 --- a/rc.c +++ b/rc.c @@ -1217,9 +1217,22 @@ void tick(void) { } } else if (gtime == nexthurryup + 15) { // 15 secs after hurryup if (!levelcomplete) { - sprite_t *bc; - bc = addsprite(P_BLACKCLOUD, 320,240,"cloud"); - makeinvuln(bc); + sprite_t *bc,*s2; + int found; + + // does cloud already exist? (could happen if someone + // picked up the whistle powerup) + + for (s2 = sprite; s2 ; s2 = s2->next) { + if (s2->id == P_BLACKCLOUD) { + found = B_TRUE; + break; + } + } + if (!found) { + bc = addsprite(P_BLACKCLOUD, 320,240,"cloud"); + makeinvuln(bc); + } addoutlinetext(320,240,TEXTSIZE_HURRY, "Too slow!", &red,&black,HURRYDELAY, TT_NORM); playfx(FX_TOOSLOW); } diff --git a/shared.c b/shared.c index 3b1e2e6..3214f4f 100644 --- a/shared.c +++ b/shared.c @@ -1284,6 +1284,9 @@ int loadimagesets(void) { SDL_Surface *tempimg; SDL_Surface *reds; SDL_Surface *origi; + SDL_Rect redarea,temparea; + int x,y; + SDL_Color tempcol; char tempfile[BUFLEN]; sprintf(tempfile, "%s/sprites/gravestone.png",datadir); @@ -1986,12 +1989,9 @@ int loadimagesets(void) { // manual angry image for black cloud - origi = imageset[P_BLACKCLOUD].img[0]; - reds = SDL_CreateRGBSurface(SDL_SWSURFACE, - origi->w, - origi->h, + reds = SDL_CreateRGBSurface(SDL_SWSURFACE,2,2, origi->format->BitsPerPixel, origi->format->Rmask, origi->format->Gmask,origi->format->Bmask, 0); SDL_FillRect(reds, NULL, SDL_MapRGB(reds->format, 255, 0, 0)); @@ -2000,20 +2000,24 @@ int loadimagesets(void) { // take a copy of the original image imageset[P_BLACKCLOUD].img[MAXFRAMES*2] = rotozoomSurfaceXY(origi, 0, 1,1,0); + redarea.x = 0; redarea.y = 0; + redarea.w = 1; redarea.h = 1; + temparea.w = 1; temparea.h = 1; - // paste the transparent one on top of it - SDL_BlitSurface(reds, NULL, imageset[P_BLACKCLOUD].img[MAXFRAMES*2], NULL); - SDL_FreeSurface(reds); + for (y = 0; y < imageset[P_BLACKCLOUD].img[MAXFRAMES*2]->h; y++) { + for (x = 0; x < imageset[P_BLACKCLOUD].img[MAXFRAMES*2]->w; x++) { - // Convert the reddened image to the screen format - tempsurf = SDL_DisplayFormat(imageset[P_BLACKCLOUD].img[MAXFRAMES*2]); - SDL_FreeSurface(imageset[P_BLACKCLOUD].img[MAXFRAMES*2]); - imageset[P_BLACKCLOUD].img[MAXFRAMES*2] = tempsurf; - - // Make the background red bits completely transparent - SDL_SetColorKey(imageset[P_BLACKCLOUD].img[MAXFRAMES*2], - SDL_SRCCOLORKEY, SDL_MapRGB(imageset[P_BLACKCLOUD].img[MAXFRAMES*2]->format, 99, 0, 0)); + getpixelrgb(imageset[P_BLACKCLOUD].img[MAXFRAMES*2] , x, y, &tempcol); + // if pixel isn't transparent... + if (tempcol.unused > 0 ) { + temparea.x = x; + temparea.y = y; + // make this pixel redder + SDL_BlitSurface(reds, &redarea, imageset[P_BLACKCLOUD].img[MAXFRAMES*2], &temparea); + } + } + } /* generate rotated/flipped images */ for (p = 0; p < MAXPTYPES; p++) {