This time I'm quite confused by what is happening in this assignment:
http://www.devmaster...e-dev/part9.php
Here's what I got:
Sprite theSprite( new Surface("assets/ctankbase.tga"), 1 );
int alpha = 255;
void Game::Tick( float a_DT )
{
m_Screen->Clear( 0 );
if( alpha <= 0 ) return;
theSprite.Draw( 0, 0, m_Screen );
int mask = alpha << 24;
Pixel* address = m_Screen->GetBuffer();
for ( int i = 0; i < 640*480; i++ ){
int color = address[i];
int masked = (color & mask);
address[i] = masked;
}
alpha = alpha - 5; //Decrease it (slowly)
}
The 24 you see in the mask variable works when it is 16(fades in red), 8(fades in green) or 0(fades in blue), though 24 wont work for some reason.
So my question is, why would it not work? I thought that if I make the mask at the alpha channel, and use the bitwise-& to extract the alpha channel, it'd fade out to black slowly.
I've also tried changing the RGB values to alpha, that way they do fade out, but in a weird way.
Thanks..












