Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » i am stuck on step 2

This thread is locked; no one can reply to it. rss feed Print
i am stuck on step 2
krabby
Member #23,052
April 2022

1. generates an 800x800 initial black window

2. Fills an outermost square of size 800x800 400 using the color green... (0, 255, 0)

3. Now put a loop around this box drawer. Each time through the loop, fill a box with sides of 4 pixels less than the prior box drawn AND which is a color 2 shades less of green and 2 shades more of red. Make sure every box is centered at coordinate (400,400) which is the center of the window.

4. When the loop reaches a box of side-size 0, stop and pause (so I can see the beautiful square-gradient you made, till I press a key).
5. Blank the whole window white.
Then draw concentric triangles, the outermost on has 3 points: <0,0>, <800,0>, and <400,800>. Now loop, going in 4 pixels each time for all 3 corners and shading with the scheme above. Make sure the lines look parallel. Stop and pause when you reach the single point in the middle.

DanielH
Member #934
January 2001
avatar

square is same size as window? Then just clear screen. What does the 400 mean?

krabby
Member #23,052
April 2022

yes is square as windows i assume. they aren't any other square.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

krabby
Member #23,052
April 2022

#include <allegro.h>

int main()
{
allegro_init();

set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,800,0,0);

rectfill(screen,0,800,0,800, makecol(0,255,0));


return 0;

}

END_OF_MAIN();

the program closing itself. how can i fix it?

LennyLen
Member #5,313
December 2004
avatar

This will stop the program from closing. Pressing Esc will make it exit. I also fixed up the co-ordinates of the rectfill function for you.

#SelectExpand
1#include <allegro.h> 2 3int main() 4{ 5 allegro_init(); 6 install_timer(); // edit: forgot this earlier, I think it's needed. edit2: definitely needed as rest is being used, but possibly also needed for keyboard routines. 7 install_keyboard(); 8 9 set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,800,0,0); 10 11 rectfill(screen, 0, 0, 800,800, makecol(0,255,0)); 12 13 while (!key[KEY_ESC]) { 14 rest(0); 15 } 16 17 return 0; 18 19} 20 21END_OF_MAIN()

By the way, unless you have a very good reason (eg. targeting older hardware), you'd be better learning Allegro 5 than Allegro 4, which is no longer actively developed.

Mark Oates
Member #1,146
March 2001
avatar

krabby, did you find out about Allegro recently? Where you found it, did it suggest to use Allegro 4?

--
Visit CLUBCATT.com for cat shirts, cat mugs, puzzles, art and more <-- coupon code ALLEGRO4LIFE at checkout and get $3 off any order of 3 or more items!

AllegroFlareAllegroFlare DocsAllegroFlare GitHub

Chris Katko
Member #1,881
January 2002
avatar

please. please. stop using allegro 4.

It was designed *for DOS*. (with roots going back to the *Amiga*)

Allegro 5, is still C based, and a thousand times better.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

LennyLen
Member #5,313
December 2004
avatar

It was designed for DOS. (with roots going back to the Amiga)

I believe it was actually the Atari ST, not the Amiga.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Chris Katko
Member #1,881
January 2002
avatar

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

{"name":"5239042.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/f\/df99f7688267bbefaa703ab1d991dba4.jpg","w":375,"h":240,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/d\/f\/df99f7688267bbefaa703ab1d991dba4"}5239042.jpg

Go to: