home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / exc.arj / TEMP / 12-05.C < prev    next >
Text File  |  1995-01-20  |  1KB  |  62 lines

  1. #include <fastgraf.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. void main(void);
  6.  
  7. #define VISUAL 0
  8. #define HIDDEN 1
  9.  
  10. void main()
  11. {
  12.    int new_mode, old_mode;
  13.    int frame, offset;
  14.    int i;
  15.  
  16.    /* initialize the video environment */
  17.  
  18.    fg_initpm();
  19.    new_mode = fg_bestmode(320,200,2);
  20.    if (new_mode < 0 || new_mode == 12)
  21.    {
  22.       printf("This program requires a 320 ");
  23.       printf("x 200 color graphics mode.\n");
  24.       exit(1);
  25.    }
  26.    old_mode = fg_getmode();
  27.    fg_setmode(new_mode);
  28.    fg_allocate(HIDDEN);
  29.  
  30.    /* draw the background in the upper left corner */
  31.  
  32.    fg_setpage(HIDDEN);
  33.    fg_setcolor(1);
  34.    fg_rect(0,95,0,49);
  35.    fg_setcolor(15);
  36.    fg_move(48,25);
  37.    fg_ellipse(20,20);
  38.  
  39.    /* copy it to the center of the visual page */
  40.  
  41.    fg_transfer(0,95,0,49,112,124,HIDDEN,VISUAL);
  42.  
  43.    /* slide the object across the background three times */
  44.  
  45.    fg_setcolor(10);
  46.    for (i = 0; i < 36; i++)
  47.    {
  48.       frame  = i % 12;
  49.       offset = 10 * frame - 10;
  50.       fg_transfer(0,95,20,29,112,105,HIDDEN,HIDDEN);
  51.       fg_rect(112+offset,131+offset,96,105);
  52.       fg_transfer(112,207,96,105,112,105,HIDDEN,VISUAL);
  53.       fg_waitfor(2);
  54.    }
  55.  
  56.    /* restore the original video mode and return to DOS */
  57.  
  58.    fg_freepage(HIDDEN);
  59.    fg_setmode(old_mode);
  60.    fg_reset();
  61. }
  62.