i am stuck on step 2
krabby

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

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

krabby

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

Edgar Reynaldo
krabby

#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

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

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

Chris Katko

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.

LennyLen

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

Clearly this is homework, and his professor is assigning allegro 4.

Chris Katko
Edgar Reynaldo

{"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

Thread #618657. Printed from Allegro.cc