Fix regression with per-pixel collision colors

In previous versions, the game mistakenly checked the wrong color
channel of sprites, checking the red channel instead of the alpha
channel. I abuse this in some of my levels. Then I broke it when
refactoring masks so the game now no longer checks the red channel but
seems to check the blue channel instead. So re-fix this to the previous
bug, and preserve the previous bug with a comment explaining why.
This commit is contained in:
Misa 2021-10-06 23:18:58 -07:00
parent 2f25ab77b1
commit 449526bb4f
1 changed files with 5 additions and 1 deletions

View File

@ -1656,7 +1656,11 @@ bool Graphics::Hitest(SDL_Surface* surface1, point p1, SDL_Surface* surface2, po
{
Uint32 pixel1 = ReadPixel(surface1 , x - p1.x, y - p1.y);
Uint32 pixel2 = ReadPixel(surface2 , x - p2.x, y - p2.y);
if ((pixel1 & 0x000000FF) && (pixel2 & 0x000000FF))
/* INTENTIONAL BUG! In previous versions, the game mistakenly
* checked the red channel, not the alpha channel.
* We preserve it here because some people abuse this. */
if ((pixel1 & surface1->format->Rmask)
&& (pixel2 & surface2->format->Rmask))
{
return true;
}