|
Question about a function in Allegro 4.4 |
Walid Jabari
Member #16,839
April 2018
|
Hello, I know allegro 4.4 is outdated but we have to use it for a school project. I can't figure out how to use the fade_in and fade_out functions. In this code : https://gist.github.com/walidjabari/c2c58f27ecb826e83c6eba7ab5e1f79b I'm trying to make use of the fade_out(int speed) function in order to fade out from a green to a black screen, but it doesn't seem to be working properly. Thank you for your help ! |
Polybios
Member #12,293
October 2010
|
You can't, since you are probably not using 8 bit colour for your desktop colour depth. |
Walid Jabari
Member #16,839
April 2018
|
Okay, thank's for the reply. What would be best way to fade in/fade out a bitmap in allegro 4.4 ? |
Chris Katko
Member #1,881
January 2002
|
Allegro 4 can use 16/32-bit color. Do you explicitly NEED 8-bit color? -----sig: |
Walid Jabari
Member #16,839
April 2018
|
I am just trying to fade in/fade out bitmaps to the screen. I can't figure out how to make proper usage of the functions fade_in(const PALETTE p, int speed) and fade_out(int speed) I just commented my code to allow a better understanding of what I'm trying to do Thanks for the help |
Edgar Reynaldo
Major Reynaldo
May 2007
|
You're not using 8-bit color, so there's no PALETTE. You'll need to interpolate between the two colors yourself, and perform a manual fade. 1void Fade(int r1 , int g1 , int b1 , int r2 , int g2 , int b2 , double duration) {
2
3 double pct = 1.0;
4 int NFRAMES = 60*duration;
5 double dt = duration/NFRAMES;
6 double elapsed = 0.0;
7
8 for (int i = 0 ; i < NFRAMES + 1; ++i) {
9 double percent = (double)i/NFRAMES;
10 clear_to_color(screen , makecol(r1 + (r2-r1)*percent ,
11 g1 + (g2-g1)*percent ,
12 b1 + (b2-b1)*percent));
13 if (keypressed()) {
14 break;
15 }
16 rest(dt*1000);
17 }
18}
EDIT My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Chris Katko
Member #1,881
January 2002
|
Also, if you can use Allegro 5, use that instead. It's pretty much better for everything except super-retro games that run in DOS. -----sig: |
Walid Jabari
Member #16,839
April 2018
|
Thank you, I understand now. Is it possible to apply the same thing with BITMAPS? |
Edgar Reynaldo
Major Reynaldo
May 2007
|
I believe you can achieve transparent blending in Allegro 4 using set_trans_blender and draw_trans_sprite. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Walid Jabari
Member #16,839
April 2018
|
Yes!! it worked. |
|