Hicolor Fades
By: Praetor
(the following was originally to be posted to the v-rpg help board, but due to size constraints, this article was thought to be the better medium)
Fading out is easy... just do something like this:
/* Pseudocode, will not compile */
done = HOW_LONG_TO_FADE_FOR;
Render(); // Repaints the map on the screen
SetLucent(1); // Makes it so that anything drawn after
// it is translucent instead of opaque
While(done) // While we are still fading
{
RectFill(COLOR_TO_FADE_TO); // Draw a translucent
// box the size of the
// screen in order to
// make everything
// below it look darker
Delay(SPEED_OF_YOUR_FADE); // Pause so it isn't
// done instantaneously.
done--; // This prevents an
// infinite loop.
ShowPage(); // To show our progress
}
SetLucent(0); // Now everything is
// opaque again.
RectFill(COLOR_TO_FADE_TO); // Draw a solid box
/* And you're faded out... */
Now, in order to fade in using that method, it requires a little more work...
/* Pseudocode again */
done = HOW_LONG_TO_FADE_FOR;
SetLucent(0);
RectFill(SOLID_COLOR_TO_FADE_FROM);
SetLucent(1);
while(done)
{
Render();
for(i=0;i<done;i++)
{
RectFill(COLOR_TO_FADE_FROM);
}
ShowPage();
Delay(SPEED_OF_YOUR_FADE);
done--;
}
SetLucent(0);
Render();
ShowPage();
/* End Pseudocode */
Okay...this one is easier to just explain in a block like this:
First you cover the screen with the color you want to fade from. Next you SetLucent(1); to make everything that follows transparent. Now, inside the while loop, you redraw the map you're fading into, then you use a for loop draw a number of translucent rectangles over the screen (since each one makes the screen progressively darker) and you want to draw less of them as the loop gets closer to being done which is why you use done like you do. Finally, you show the page and use Delay to slow down the engine a little to make it visibly fade rather than just whip through the whole thing... Finally, after the loop you SetLucent(0); to turn off transparency, and then redraw and show the completely uncovered map.
Well, you'll have to monkey with the values to get the fade just how you want it, but that should give you a good idea of how to do it.
Now, I make no guarentees to the working of that code...It's untested and just pulled straight out of a rather tired brain.
But at least, it should be enough to get you started.
Happy Holidays!