- #include <allegro.h>
- #include <cstdlib>
- #include <ctime>
- #include <windows.h>
- #define HEIGHT 640
- #define WIDTH 480
- void draw(int h, int w);
- void draw_random();
- int main()
- {
- allegro_init();
- srand(time(NULL));
- set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
- install_keyboard();
- clear_to_color(screen,makecol(255,255,255));
- draw(0,0);
- Sleep(3000);
- clear_to_color(screen,makecol(255,255,255));
- draw_random();
- while((readkey()& 0xff) != 27);
- allegro_exit();
- return 0;
- }
- END_OF_MAIN()
- void draw(int h, int w)
- {
- circle(screen,screen->w/2,screen->h/2,100, makecol(40,40,40));
- rect(screen,(screen->w/3),(screen->h/3),(screen->w/1.5),(screen->h/1.5), makecol(80,80,80));
- triangle(screen,(screen->w/3), (screen->h/2), (screen->w/2), (screen->h/4), (screen->w/1.5), (screen->h/2), makecol(120,120,120));
- line(screen, screen->w/4, screen->h/4.5, screen->w/1.25, screen->h/4.5, makecol(200,200,200));
- line(screen, screen->w/4, screen->h/1.25, screen->w/1.25, screen->h/1.25, makecol(200,200,200));
- line(screen, screen->w/4, screen->h/1.25, screen->w/4, screen->h/4.5, makecol(200,200,200));
- line(screen, screen->w/1.25, screen->h/1.25, screen->w/1.25, screen->h/4.5, makecol(200,200,200));
- }
- void draw_random()
- {
- int x1 = rand()%screen->w;
- int y1 = rand()%screen->h;
- int random = rand()%screen->h/3;
- circle(screen, rand()%screen->w, rand()%screen->h, rand()%320, makecol(rand()%255,rand()%255,rand()%255));
- line(screen, rand()%screen->w, rand()%screen->h, rand()%screen->w, rand()%screen->h, makecol(rand()%255,rand()%255,rand()%255));
- rect(screen, x1, y1, x1+random , y1+random, makecol(rand()%255,rand()%255,rand()%255));
- triangle(screen, x1, y1, x1+random, y1, (x1+random/2), (y1+random), makecol(rand()%255,rand()%255,rand()%255));
- }