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:
parent
336a0798fa
commit
f51dbd0669
|
@ -81,19 +81,19 @@ void loadGameGraphics()
|
||||||
fclose(fp);
|
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++)
|
for (int i = SHIP_HIT_INDEX ; i < MAX_SHIPSHAPES ; i++)
|
||||||
{
|
{
|
||||||
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
|
if (shipShape[i - SHIP_HIT_INDEX] == NULL)
|
||||||
continue;
|
continue;
|
||||||
shipShape[i] = createSurface(shipShape[i - SHIP_HIT_INDEX]->w, shipShape[i- SHIP_HIT_INDEX]->h);
|
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]);
|
blit(shipShape[i - SHIP_HIT_INDEX], 0, 0, shipShape[i]);
|
||||||
hitRect = alphaRect(shipShape[i]->w, shipShape[i]->h, 255, 0, 0);
|
uint32_t *p = (uint32_t *)shipShape[i]->pixels;
|
||||||
blit(hitRect, 0, 0, shipShape[i]);
|
for(int j = 0; j < shipShape[i]->w * shipShape[i]->h; j++)
|
||||||
SDL_SetColorKey(shipShape[i], (SDL_SRCCOLORKEY|SDL_RLEACCEL), SDL_MapRGB(shipShape[i]->format, 127, 0, 0));
|
if(p[j])
|
||||||
SDL_FreeSurface(hitRect);
|
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");
|
strcpy(string, "data/resources_all.dat");
|
||||||
|
|
Loading…
Reference in New Issue