|
Fading |
Neil Black
Member #7,867
October 2006
|
How can I do a fade in or fade out when I'm not using a palette? Also, how can I do a day/night cycle where the screen slowly darkens to night when I'm not using a palette?
|
gnolam
Member #2,030
March 2002
|
The easiest way is to draw a transparent black rectangle over the screen (buffer). int alpha = 128; //arbitrary value for demonstration purposes drawing_mode(DRAW_MODE_TRANS); set_trans_blender(0, 0, 0, alpha); rectfill(buffer, 0, 0, buffer->w, buffer->h, makecol(0, 0, 0)); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
Quote: Also, how can I do a day/night cycle where the screen slowly darkens to night when I'm not using a palette? Depends on what kind of effect you're after. For a simple "everything turns darker" effect, see the code snippet above. -- |
Neil Black
Member #7,867
October 2006
|
Okay, in 16 bit mode I thought there wasn't an alpha value. I should have mentioned that I'm using a 16 bit color depth. Will that still work? And the day/night cycle needs to fade to night, where the colors are darker and seem more bluish, and then back to day. I could have separate tiles for day and night, but there would be problems during the transition. Whatever I do has to be fast enough to run during game play.
|
Kauhiz
Member #4,798
July 2004
|
Quote: Okay, in 16 bit mode I thought there wasn't an alpha value. There isn't, that's why you have to supply it separately. In 32bpp you could have the alpha values stored in the bitmap. --- |
ImLeftFooted
Member #3,935
October 2003
|
const int cycles = 60 * 3; for(int i = 0; i <= cycles; i++) { conf.beginScene(); drawGame(); Bitmap::rect(0, 0, 640, 480, Tint(1, 1, 1, float(i) / cycles); conf.flip(); }
|
Neil Black
Member #7,867
October 2006
|
okay, dustin dettmer, you have several things I've never seen before in that code snippet, like Tint(...). is that an allegro function or just something you wrote that does what gnolam said? I also don't know what conf.beginScene() or
|
GullRaDriel
Member #3,861
September 2003
|
It looks like openlayer thing. "Code is like shit - it only smells if it is not yours" |
Neil Black
Member #7,867
October 2006
|
Openlayer? oh crap, more things-I-don't-understand-but-need-to! I thought I was through with that after I learned to tie my own shoes when I was 17
|
ImLeftFooted
Member #3,935
October 2003
|
Its actually from the Thing library. Which will soon be merged with OL (aka once I get some free time). |
Steve Terry
Member #1,989
March 2002
|
In 16-bit you can basically do a fast fade by packing two bytes into a 32-bit register. Here is the code I used:
Well maybe not... I think I had a better function that didn't require a temporary bitmap... but meh? ___________________________________ |
Neil Walker
Member #210
April 2000
|
Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Neil Black
Member #7,867
October 2006
|
Gnolam's method seems to be the easiest, so I tried it first. Works perfectly! Thanks guys
|
|