home *** CD-ROM | disk | FTP | other *** search
/ Virtual Reality Zone / VRZONE.ISO / mac / PC / REND386 / UTILS / PLGSTARS / PLGSTARS.C < prev    next >
C/C++ Source or Header  |  1992-11-09  |  844b  |  31 lines

  1. /* Generate a star field as a .PLG file */
  2.  
  3. /* Written by Bernie Roehl, November 1992 */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7.  
  8. int starcount = 100;    /* number of stars to generate */
  9. int colorflag = 0;        /* if non-zero, generate random star colors */
  10.  
  11. #define FSIZE 1000      /* size of the starfield box */
  12.  
  13. #define STARCOLOR 15    /* stars are, by default, white */
  14.  
  15. void main(int argc, char *argv[])
  16.     {
  17.     int i;
  18.     randomize();
  19.     while (argc > 1) {
  20.         if (!stricmp(argv[1], "-c")) colorflag = 1;
  21.         else starcount = atoi(argv[1]);
  22.         --argc;
  23.         ++argv;
  24.         }
  25.     printf("starfield %d %d\n", starcount, starcount);
  26.     for (i = 0; i < starcount; ++i)
  27.         printf("%d %d %d\n", random(FSIZE), random(FSIZE), random(FSIZE));
  28.     for (i = 0; i < starcount; ++i)
  29.         printf("0x%04.4X 1 %d\n", colorflag ? (random(15) + 1) : STARCOLOR, i);
  30.     }
  31.