Use a better way to create images of ships taking damage.

The old technique was to overlay a semi-transparent red rectangle over an
existing ship image, and then make 50% red pixels transparent. For some reason,
the transparency is not working correctly. Instead, don't overlay anything,
but set the red component of all non-black pixels to the maximum value.
This commit is contained in:
Guus Sliepen 2012-02-28 13:35:39 +01:00
parent 336a0798fa
commit f51dbd0669
1 changed files with 6 additions and 6 deletions

View File

@ -81,19 +81,19 @@ void loadGameGraphics()
fclose(fp);
/*
Overlay a red alpha surface onto
Create images of ships being hit that show a lot of red
*/
SDL_Surface *hitRect;
for (int i = SHIP_HIT_INDEX ; i < MAX_SHIPSHAPES ; i++)
{
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
continue;
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w, shipShape[i- SHIP_HIT_INDEX]->h);
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
hitRect = alphaRect(shipShape[i]->w, shipShape[i]->h, 255, 0, 0);
blit(hitRect, 0, 0, shipShape[i]);
SDL_SetColorKey(shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(shipShape[i]->format, 127, 0, 0));
SDL_FreeSurface(hitRect);
uint32_t *p = (uint32_t *)shipShape[i]->pixels;
for(int j = 0; j < shipShape[i]->w * shipShape[i]->h; j++)
if(p[j])
p[j] |= shipShape[i]->format->Rmask;
SDL_SetColorKey(shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(shipShape[i]->format, 0, 0, 0));
}
strcpy(string, "data/resources_all.dat");