home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / exc.arj / TEMP / 06-12.C < prev    next >
Text File  |  1995-01-31  |  813b  |  42 lines

  1. #include <fastgraf.h>
  2. #include <stdlib.h>
  3.  
  4. void main(void);
  5.  
  6. #define RECTANGLES 200
  7. #define SWAP(a,b,temp) { temp = a; a = b; b = temp; }
  8.  
  9. void main()
  10. {
  11.    int i;
  12.    int minx, maxx, miny, maxy;
  13.    int old_mode;
  14.    int temp;
  15.    int xres, yres;
  16.  
  17.    fg_initpm();
  18.    old_mode = fg_getmode();
  19.    fg_setmode(fg_automode());
  20.    fg_boxdepth(3,3);
  21.  
  22.    xres = fg_getmaxx() + 1;
  23.    yres = fg_getmaxy() + 1;
  24.  
  25.    for (i = 0; i < RECTANGLES; i++)
  26.    {
  27.       minx = rand() % xres;
  28.       maxx = rand() % xres;
  29.       miny = rand() % yres;
  30.       maxy = rand() % yres;
  31.       if (minx > maxx)
  32.          SWAP(minx,maxx,temp);
  33.       if (miny > maxy)
  34.          SWAP(miny,maxy,temp);
  35.       fg_setcolor(rand()%16);
  36.       fg_box(minx,maxx,miny,maxy);
  37.    }
  38.  
  39.    fg_setmode(old_mode);
  40.    fg_reset();
  41. }
  42.