home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / exc.arj / TEMP / 17-02.C < prev    next >
Text File  |  1995-01-20  |  943b  |  49 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. #define RECTANGLES 200
  8. #define SWAP(a,b,temp) { temp = a; a = b; b = temp; }
  9.  
  10. void main()
  11. {
  12.    int i;
  13.    int minx, maxx, miny, maxy;
  14.    int old_mode;
  15.    int temp;
  16.    int xres, yres;
  17.  
  18.    fg_initpm();
  19.    if (fg_egacheck() == 0)
  20.    {
  21.       printf("This program requires EGA or VGA.\n");
  22.       exit(1);
  23.    }
  24.  
  25.    old_mode = fg_getmode();
  26.    fg_setmode(fg_automode());
  27.    fg_setfunc(3);
  28.  
  29.    xres = fg_getmaxx() + 1;
  30.    yres = fg_getmaxy() + 1;
  31.  
  32.    for (i = 0; i < RECTANGLES; i++)
  33.    {
  34.       minx = rand() % xres;
  35.       maxx = rand() % xres;
  36.       miny = rand() % yres;
  37.       maxy = rand() % yres;
  38.       if (minx > maxx)
  39.          SWAP(minx,maxx,temp);
  40.       if (miny > maxy)
  41.          SWAP(miny,maxy,temp);
  42.       fg_setcolor(rand()%16);
  43.       fg_rect(minx,maxx,miny,maxy);
  44.    }
  45.  
  46.    fg_setmode(old_mode);
  47.    fg_reset();
  48. }
  49.