home *** CD-ROM | disk | FTP | other *** search
/ C++ Games Programming / CPPGAMES.ISO / fgl / fglight / manuals.arj / USER12.DOC < prev    next >
Text File  |  1995-02-06  |  26KB  |  654 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7. Chapter 12
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Animation Techniques                                                           
  14. 274   Fastgraph User's Guide
  15.  
  16.  
  17. Overview
  18.  
  19.      Unlike other microcomputers, the IBM PC and PS/2 family of systems do not
  20. have any special graphics hardware or firmware to help in performing
  21. animation. This means any animation done on these systems must be implemented
  22. entirely through software. This chapter will show how to do this using
  23. Fastgraph's video page management, image display, and block transfer routines.
  24. The methods described in this chapter are not intended to be all inclusive,
  25. for that would itself fill a separate volume at least as large as this manual.
  26. However, the animation techniques presented here should provide a basis that
  27. you can readily extend to develop more sophisticated uses of animation. The
  28. examples in this chapter are restricted to graphics video modes.
  29.  
  30.  
  31. Simple Animation
  32.  
  33.      The first type of animation we'll examine is called simple animation. In
  34. simple animation, we display an object, erase it, and then display it in a new
  35. position. When we perform this "erase and redisplay" sequence repetitively,
  36. the object moves. This method, however, has two drawbacks. First, unless the
  37. object is rather small, it will flicker because the erasing and display of the
  38. object does not coincide with the refresh rate of the video display. Second,
  39. and perhaps more importantly, anything underneath the object is not saved as
  40. the object moves across it. Despite these limitations, simple animation is
  41. sometimes useful, and it is a good place to begin our discussion of animation
  42. techniques.
  43.  
  44.      Example 12-1 moves a small bright green rectangle (magenta in CGA) from
  45. left to right across the screen in any 320x200 color graphics mode. The
  46. program moves the rectangle, 20 pixels wide and 10 pixels high, using a for
  47. loop. This loop first uses fg_clprect to display the rectangle, then uses
  48. fg_waitfor to leave the object on the screen momentarily, and finally uses
  49. fg_clprect again to erase the rectangle by redisplaying it in the original
  50. background color (fg_waitfor is described in Chapter 16). We use fg_clprect
  51. rather than fg_rect because the first few and last few loop iterations result
  52. in at least part of the rectangle being off the screen. Each successive loop
  53. iteration displays the rectangle five pixels to the right of its previous
  54. position.
  55.  
  56.                                  Example 12-1.
  57.  
  58.           #include <fastgraf.h>
  59.           #include <stdio.h>
  60.           #include <stdlib.h>
  61.           void main(void);
  62.  
  63.           void main()
  64.           {
  65.              int new_mode, old_mode;
  66.              int x;
  67.  
  68.              /* initialize the video environment */
  69.  
  70.              fg_initpm();
  71.              new_mode = fg_bestmode(320,200,1);                                
  72.                                        Chapter 12:  Animation Techniques   275
  73.  
  74.              if (new_mode < 0 || new_mode == 12) {
  75.                 printf("This program requires a 320 ");
  76.                 printf("x 200 color graphics mode.\n");
  77.                 exit(1);
  78.                 }
  79.              old_mode = fg_getmode();
  80.              fg_setmode(new_mode);
  81.  
  82.              /* move the object across the screen */
  83.  
  84.              for (x = -20; x < 320; x+=5) {
  85.                 fg_setcolor(10);
  86.                 fg_clprect(x,x+19,95,104);
  87.                 fg_waitfor(1);
  88.                 fg_setcolor(0);
  89.                 fg_clprect(x,x+19,95,104);
  90.                 }
  91.  
  92.              /* restore the original video mode and return to DOS */
  93.  
  94.              fg_setmode(old_mode);
  95.              fg_reset();
  96.           }
  97.  
  98.  
  99.      Example 12-2 is the same as example 12-1, but it shows what happens when
  100. we move the rectangle across an existing background (in this case, the
  101. background is solid white). If you run this program, you'll see that the
  102. rectangle leaves a trail of color 0 pixels behind it. While this might be
  103. occasionally useful, it demonstrates that simple animation is destructive
  104. because it does not preserve the background. In this example, if we changed
  105. the second call to fg_setcolor within the for loop to revert to color 15
  106. instead of color 0, the background would be restored. In general, though, it
  107. may not be this easy to replace the background, so we must rely on some other
  108. method for preserving it.
  109.  
  110.                                  Example 12-2.
  111.  
  112.           #include <fastgraf.h>
  113.           #include <stdio.h>
  114.           #include <stdlib.h>
  115.           void main(void);
  116.  
  117.           void main()
  118.           {
  119.              int new_mode, old_mode;
  120.              int x;
  121.  
  122.              /* initialize the video environment */
  123.  
  124.              fg_initpm();
  125.              new_mode = fg_bestmode(320,200,1);
  126.              if (new_mode < 0 || new_mode == 12) {
  127.                 printf("This program requires a 320 ");
  128.                 printf("x 200 color graphics mode.\n");
  129.                 exit(1);                                                       
  130. 276   Fastgraph User's Guide
  131.  
  132.                 }
  133.              old_mode = fg_getmode();
  134.              fg_setmode(new_mode);
  135.  
  136.              /* draw some type of background */
  137.  
  138.              fg_setcolor(15);
  139.              fg_rect(0,319,0,199);
  140.  
  141.              /* move the object across the screen */
  142.  
  143.              for (x = -20; x < 320; x+=5) {
  144.                 fg_setcolor(10);
  145.                 fg_clprect(x,x+19,95,104);
  146.                 fg_waitfor(1);
  147.                 fg_setcolor(0);
  148.                 fg_clprect(x,x+19,95,104);
  149.                 }
  150.  
  151.              /* restore the original video mode and return to DOS */
  152.  
  153.              fg_setmode(old_mode);
  154.              fg_reset();
  155.           }
  156.  
  157.  
  158.      To summarize, we've seen that simple animation is easy to implement, but
  159. it is destructive and typically causes the animated object to flicker. For
  160. these reasons, it is not used too frequently.
  161.  
  162.  
  163. XOR Animation
  164.  
  165.      "Exclusive or" animation, or XOR animation for short, is an interesting
  166. extension of simple animation and is most useful when animating a single-color
  167. object against a single-color background. Like simple animation, it uses the
  168. "erase and redisplay" technique to move an object, but it does this
  169. differently. Instead of erasing the object by displaying it in the background
  170. color, XOR animation does so by displaying it in the same color using an
  171. exclusive or, or XOR, operation. This method relies on a specific property of
  172. the exclusive or operator:
  173.  
  174.                 (object XOR background) XOR object = background
  175.  
  176. In other words, if you XOR something twice in the same position, the result is
  177. the same as the original image in that position.
  178.  
  179.      Example 12-3 demonstrates XOR animation. This program is similar to
  180. example 12-2, but it only runs in the 320x200 EGA graphics mode (mode 13).
  181. After establishing the video mode, it uses the Fastgraph routine fg_setfunc to
  182. select XOR mode. This causes any subsequent graphics output to be XORed with
  183. the contents of video memory instead of just replacing it. The fg_setfunc
  184. routine is described further in Chapter 17.
  185.  
  186.      The other differences between examples 12-3 and 12-2 are that the call to
  187. fg_setcolor has been moved outside the for loop, and that fg_setcolor takes a  
  188.                                        Chapter 12:  Animation Techniques   277
  189.  
  190. different value. Since the existing background is bright white (color 15), we
  191. can't just use color 10 if we want to display a bright green object. The
  192. desired value is that which when XORed with color 15 produces color 10; the
  193. easiest way to obtain this value is to XOR these two numbers. The call to
  194. fg_setcolor can be moved outside the loop because we display the object using
  195. the same color index throughout.
  196.  
  197.                                  Example 12-3.
  198.  
  199.           #include <fastgraf.h>
  200.           #include <stdio.h>
  201.           #include <stdlib.h>
  202.           void main(void);
  203.  
  204.           void main()
  205.           {
  206.              int old_mode;
  207.              int x;
  208.  
  209.              /* initialize the video environment */
  210.  
  211.              fg_initpm();
  212.              if (fg_testmode(13,1) == 0) {
  213.                 printf("This program requires EGA.\n");
  214.                 exit(1);
  215.                 }
  216.              old_mode = fg_getmode();
  217.              fg_setmode(13);
  218.              fg_setfunc(3);
  219.  
  220.              /* draw some type of background */
  221.  
  222.              fg_setcolor(15);
  223.              fg_rect(0,319,0,199);
  224.  
  225.              /* move the object across the screen */
  226.  
  227.              fg_setcolor(10^15);
  228.              for (x = -20; x < 320; x+=5) {
  229.                 fg_clprect(x,x+19,95,104);
  230.                 fg_waitfor(1);
  231.                 fg_clprect(x,x+19,95,104);
  232.                 }
  233.  
  234.              /* restore the original video mode and return to DOS */
  235.  
  236.              fg_setmode(old_mode);
  237.              fg_reset();
  238.           }
  239.  
  240.  
  241.      Fastgraph only supports the XOR pixel operation in the native EGA and VGA
  242. graphics video modes (modes 13 through 18) and 16-color SVGA modes (28 and
  243. 29). Thus, you cannot use XOR animation in CGA, Tandy/PCjr, Hercules, or 256-
  244. color graphics modes.                                                          
  245. 278   Fastgraph User's Guide
  246.  
  247.      While XOR animation is non-destructive (that is, it restores the original
  248. background), it still suffers from the flickering encountered in simple
  249. animation. In spite of this, it may be useful when animating a single-color
  250. object against a single-color background.
  251.  
  252.  
  253. Static Frame Animation
  254.  
  255.      Static frame animation uses a different strategy than simple animation or
  256. XOR animation. The general scheme of this method is to create the entire
  257. animation sequence off-screen and then successively display each item, or
  258. frame, in this sequence on one position of the visual video page. This results
  259. in a visually appealing animation that is non-destructive and does not include
  260. the flickering associated with simple animation and XOR animation. Static
  261. frame animation requires the visual video page and one or more additional
  262. pages (or virtual buffers) to implement. The number of pages needed depends on
  263. the number of frames and the size of each frame.
  264.  
  265.      Example 12-4 runs in any 320x200 color graphics video mode and
  266. illustrates a simple use of static frame animation. The program displays an
  267. animation sequence containing 12 frames; it displays this sequence three
  268. times. The animation sequence consists of a bright green rectangle (magenta in
  269. CGA) moving from left to right across the center of the frame. Each frame is
  270. 96 pixels wide and 50 pixels high. The 12 frames are set up on an off-screen
  271. video page as shown here:
  272.  
  273.                          0       95 96     191 192    287
  274.  
  275.                       0
  276.                           frame 1    frame 2    frame 3
  277.                      49
  278.  
  279.                      50
  280.                           frame 4    frame 5    frame 6
  281.                      99
  282.  
  283.                     100
  284.                           frame 7    frame 8    frame 9
  285.                     149
  286.  
  287.                     150
  288.                           frame 10   frame 11   frame 12
  289.                     199
  290.  
  291.  
  292.      Example 12-4 first establishes the video mode and allocates the
  293. additional video page (needed if using a video mode in which page 1 is a
  294. virtual video page). The program then generates the background for frame 1;
  295. the background is a blue rectangle (cyan in CGA) with a white ellipse centered
  296. on it. After the call to fg_ellipse, the first frame is ready.
  297.  
  298.      The next step is to create the remaining 11 frames. In frame 2, the right
  299. half of the 20-pixel wide rectangle will enter the left edge of the frame. In
  300. frame 3, the rectangle will be ten pixels farther right, or aligned against
  301. the left edge of the frame. In frames 4 through 12, the rectangle will be ten
  302. pixels farther right in each frame, so by frame 12 only the left half of the   
  303.                                        Chapter 12:  Animation Techniques   279
  304.  
  305. rectangle appears on the right edge of the frame. The first for loop in the
  306. program builds frames 2 through 12 by copying the background from frame 1 and
  307. then displaying the rectangle (that is, the animated object) in the proper
  308. position for that frame.
  309.  
  310.      The second for loop performs the animation sequence. To display the 12-
  311. frame sequence three times, it must perform 36 iterations. The loop simply
  312. copies each frame from the proper position on video page 1 to the middle of
  313. the visual video page. Note how fg_waitfor is used to pause momentarily
  314. between frames.
  315.  
  316.                                  Example 12-4.
  317.  
  318.         #include <fastgraf.h>
  319.         #include <stdio.h>
  320.         #include <stdlib.h>
  321.         void main(void);
  322.  
  323.         #define VISUAL 0
  324.         #define HIDDEN 1
  325.  
  326.         int xmin[] = {  0, 96,192,  0, 96,192,  0, 96,192,  0, 96,192};
  327.         int ymax[] = { 49, 49, 49, 99, 99, 99,149,149,149,199,199,199};
  328.  
  329.         void main()
  330.         {
  331.            int new_mode, old_mode;
  332.            int frame, offset;
  333.            int i, x, y;
  334.  
  335.            /* initialize the video environment */
  336.  
  337.            fg_initpm();
  338.            new_mode = fg_bestmode(320,200,2);
  339.            if (new_mode < 0 || new_mode == 12) {
  340.               printf("This program requires a 320 ");
  341.               printf("x 200 color graphics mode.\n");
  342.               exit(1);
  343.               }
  344.            old_mode = fg_getmode();
  345.            fg_setmode(new_mode);
  346.            fg_allocate(HIDDEN);
  347.  
  348.            /* draw the background in the upper left corner */
  349.  
  350.            fg_setpage(HIDDEN);
  351.            fg_setcolor(1);
  352.            fg_rect(0,95,0,49);
  353.            fg_setcolor(15);
  354.            fg_move(48,25);
  355.            fg_ellipse(20,20);
  356.  
  357.            /* display the animated object against each background */
  358.  
  359.            fg_setcolor(10);
  360.            offset = -10;                                                       
  361. 280   Fastgraph User's Guide
  362.  
  363.            for (i = 1; i < 12; i++) {
  364.               x = xmin[i];
  365.               y = ymax[i];
  366.               fg_transfer(0,95,0,49,x,y,HIDDEN,HIDDEN);
  367.               fg_setclip(x,x+95,0,199);
  368.               fg_clprect(x+offset,x+offset+19,y-29,y-20);
  369.               offset += 10;
  370.               }
  371.  
  372.            /* slide the object across the background three times */
  373.  
  374.            for (i = 0; i < 36; i++) {
  375.               frame = i % 12;
  376.               x = xmin[frame];
  377.               y = ymax[frame];
  378.               fg_transfer(x,x+95,y-49,y,112,124,HIDDEN,VISUAL);
  379.               fg_waitfor(2);
  380.               }
  381.  
  382.            /* restore the original video mode and return to DOS */
  383.  
  384.            fg_freepage(HIDDEN);
  385.            fg_setmode(old_mode);
  386.            fg_reset();
  387.         }
  388.  
  389.  
  390.  
  391.  
  392. Dynamic Frame Animation
  393.  
  394.      Dynamic frame animation is similar to static frame animation, but all the
  395. animation frames are built as needed during the animation sequence instead of
  396. in advance. When using this method, you must first store a copy of the
  397. background on an off-screen video page. Then, to build a frame, create another
  398. copy (called the workspace) of the background elsewhere on the off-screen page
  399. (or even to a different off-screen page) and display the object on that copy.
  400. Finally, transfer the workspace to the visual page. Like static frame
  401. animation, this method produces a non-destructive, flicker-free animation
  402. sequence.
  403.  
  404.      Example 12-5 is functionally identical to example 12-4, but it uses
  405. dynamic rather than static frame animation. As before, the program builds the
  406. background in the upper left corner of video page 1, but it then uses
  407. fg_transfer to copy it to the center of the visual video page. The for loop
  408. builds each frame as it is needed and also copies it to the center of the
  409. visual page. Again, fg_waitfor creates the necessary pause between frames.
  410.  
  411.                                  Example 12-5.
  412.  
  413.           #include <fastgraf.h>
  414.           #include <stdio.h>
  415.           #include <stdlib.h>
  416.           void main(void);
  417.  
  418.           #define VISUAL 0                                                     
  419.                                        Chapter 12:  Animation Techniques   281
  420.  
  421.           #define HIDDEN 1
  422.  
  423.           void main()
  424.           {
  425.              int new_mode, old_mode;
  426.              int frame, offset;
  427.              int i;
  428.  
  429.              /* initialize the video environment */
  430.  
  431.              fg_initpm();
  432.              new_mode = fg_bestmode(320,200,2);
  433.              if (new_mode < 0 || new_mode == 12) {
  434.                 printf("This program requires a 320 ");
  435.                 printf("x 200 color graphics mode.\n");
  436.                 exit(1);
  437.                 }
  438.              old_mode = fg_getmode();
  439.              fg_setmode(new_mode);
  440.              fg_allocate(HIDDEN);
  441.  
  442.              /* draw the background in the upper left corner */
  443.  
  444.              fg_setpage(HIDDEN);
  445.              fg_setcolor(1);
  446.              fg_rect(0,95,0,49);
  447.              fg_setcolor(15);
  448.              fg_move(48,25);
  449.              fg_ellipse(20,20);
  450.  
  451.              /* copy it to the center of the visual page */
  452.  
  453.              fg_transfer(0,95,0,49,112,124,HIDDEN,VISUAL);
  454.  
  455.              /* slide the object across the background three times */
  456.  
  457.              fg_setcolor(10);
  458.              for (i = 0; i < 36; i++) {
  459.                 frame  = i % 12;
  460.                 offset = 10 * frame - 10;
  461.                 fg_transfer(0,95,20,29,112,105,HIDDEN,HIDDEN);
  462.                 fg_rect(112+offset,131+offset,96,105);
  463.                 fg_transfer(112,207,96,105,112,105,HIDDEN,VISUAL);
  464.                 fg_waitfor(2);
  465.                 }
  466.  
  467.              /* restore the original video mode and return to DOS */
  468.  
  469.              fg_freepage(HIDDEN);
  470.              fg_setmode(old_mode);
  471.              fg_reset();
  472.           }
  473.  
  474.  
  475.      Two items in example 12-5 merit further discussion. First, we have chosen
  476. our workspace on page 1 so it uses the same screen space coordinates as the    
  477. 282   Fastgraph User's Guide
  478.  
  479. image area on the visual page. This is not necessary unless you are using
  480. fg_restore instead of fg_transfer. Second, the program can use the faster
  481. fg_rect routine in place of fg_clprect. It can do this because even though the
  482. object will extend beyond the workspace limits, we only transfer the workspace
  483. itself. However, for this to function properly, the workspace's horizontal
  484. limits must fall on byte boundaries.
  485.  
  486.      Note too that we do not need to transfer the entire frame during the
  487. animation sequence. In example 12-5, we know the vertical extremes of the
  488. moving image are y=96 and y=105, so we only transfer 10 rows instead of the
  489. entire frame. We could similarly compute the x extremes for each frame and
  490. only transfer the necessary portion. Recall, however, that fg_transfer extends
  491. the horizontal coordinates to byte boundaries, so we may copy a few extra
  492. pixels as well. This may or may not affect the animation sequence. Again, the
  493. problem is eliminated if you align your workspace on byte boundaries.
  494.  
  495.      When we use dynamic frame animation, it is easy to change the number of
  496. frames in the animation sequence. Suppose we wish to produce a smoother
  497. animation by increasing the number of frames from 12 to 24. This means the
  498. object will move in increments of five pixels instead of ten. The only changes
  499. needed are to double the number of loop iterations, modify the calculations
  500. for the frame number and offset values as shown here, and reduce the
  501. fg_waitfor pause from 2 to 1.
  502.  
  503.  
  504.                            frame  = i % 24;
  505.                            offset = 5 * frame - 10;
  506.  
  507.  
  508. Compare this to all the changes that would be necessary if we were using
  509. static frame animation.
  510.  
  511.  
  512. Page Flipping
  513.  
  514.      Page flipping is a variation of frame animation in which you construct
  515. images on off-screen video pages and then repetitively make those pages the
  516. visual page. We can further divide the page flipping technique into static and
  517. dynamic variants, as we did with frame animation.
  518.  
  519.      In static page flipping, we construct the entire animation sequence in
  520. advance, with one frame per video page. Once this is done, we can display each
  521. frame by using fg_setvpage to switch instantly from one video page to another.
  522. Although this produces a smooth, flicker-free animation, we cannot carry the
  523. sequence very far before running out of video pages (and hence animation
  524. frames).
  525.  
  526.      In dynamic page flipping, we construct each animation frame when it is
  527. needed. As in static page flipping, we construct each frame on a separate
  528. video page. However, as example 12-6 demonstrates, we only need three video
  529. pages to produce the animation sequence, regardless of the number of frames in
  530. the sequence. Two of the three video pages will alternate as the visual page,
  531. while the remaining video page keeps a copy of the background.
  532.  
  533.      Example 12-6, which performs an animation sequence similar to examples
  534. 12-4 and 12-5, illustrates dynamic frame animation in the 320x200 EGA graphics 
  535.                                        Chapter 12:  Animation Techniques   283
  536.  
  537. video mode (mode 13). The program begins by displaying the background on video
  538. page 2. Video pages 0 and 1 will alternate as the visual page; the page that
  539. is not the visual page is called the hidden page. We start with page 0 as the
  540. visual page, and hence page 1 as the hidden page. To build each frame, the
  541. program uses fg_transfer to copy the background from page 2 to the hidden page
  542. and then uses fg_clprect to display the animated object at the correct
  543. position on the hidden page. After this, it displays the next frame by using
  544. fg_setvpage to make the hidden page the visual page. Before beginning the next
  545. iteration, the program toggles the hidden page number in preparation for the
  546. next frame.
  547.  
  548.                                  Example 12-6.
  549.  
  550.           #include <fastgraf.h>
  551.           #include <stdio.h>
  552.           #include <stdlib.h>
  553.           void main(void);
  554.  
  555.           void main()
  556.           {
  557.              int old_mode;
  558.              int hidden;
  559.              int x;
  560.  
  561.              /* initialize the video environment */
  562.  
  563.              fg_initpm();
  564.              if (testmode(fg_13,3) == 0) {
  565.                 printf("This program requires EGA.\n");
  566.                 exit(1);
  567.                 }
  568.              old_mode = fg_getmode();
  569.              fg_setmode(13);
  570.  
  571.              /* draw the background on page two */
  572.  
  573.              fg_setpage(2);
  574.              fg_setcolor(1);
  575.              fg_rect(0,319,0,199);
  576.              fg_setcolor(15);
  577.              fg_move(160,100);
  578.              fg_ellipse(20,20);
  579.  
  580.              /* slide the object across the screen */
  581.  
  582.              hidden = 1;
  583.              setcolor(10);
  584.              for (x = -10; x < 320; x+=4) {
  585.                 fg_setpage(hidden);
  586.                 fg_transfer(0,319,0,199,0,199,2,hidden);
  587.                 fg_clprect(x,x+19,96,105);
  588.                 fg_setvpage(hidden);
  589.                 hidden = 1 - hidden;
  590.                 fg_waitfor(1);
  591.                 }                                                              
  592. 284   Fastgraph User's Guide
  593.  
  594.              /* restore the original video mode and return to DOS */
  595.  
  596.              fg_setmode(old_mode);
  597.              fg_reset();
  598.           }
  599.  
  600.  
  601.      A problem with either page flipping technique arises if we use virtual
  602. video pages. Page flipping relies on the fact that changing the visual page
  603. number occurs instantly, which is exactly what happens when we use physical
  604. video pages. However, such is not the case with virtual or logical pages
  605. because Fastgraph must copy the entire page contents into video memory. While
  606. this occurs quite rapidly, it is not instantaneous, and its effects are
  607. immediately apparent on the animation.
  608.  
  609.  
  610. An Animation Example: The Fastgraph Fish Tank
  611.  
  612.      If you installed the example programs when you installed Fastgraph, the
  613. EXAMPLES subdirectory will include a fully-commented program called the fish
  614. tank that illustrates dynamic frame animation. The fish tank is an excellent
  615. example of multi-object non-destructive animation in which several types of
  616. tropical fish swim back and forth against a coral reef background. As a
  617. picture is worth 1,024 words, we suggest studying the fish tank source code
  618. for some useful techniques in developing a complete animation program. The
  619. source code for the fish tank program is in FISHTANK.C, FISHTANK.BAS,
  620. FISHTANK.FOR, or FISHTANK.PAS, depending on what language support you've
  621. installed with Fastgraph.
  622.  
  623.  
  624. Summary of Animation Techniques
  625.  
  626.      This chapter has presented five animation techniques: simple animation,
  627. XOR animation, static frame animation, dynamic frame animation, and page
  628. flipping. The following table summarizes their behavior.
  629.  
  630.                technique     destructive?        flicker-free?
  631.  
  632.                simple             yes                 no
  633.                XOR                no                  no
  634.                static frame       no                  yes
  635.                dynamic frame      no                  yes
  636.                page flipping      no                  yes
  637.  
  638. Simple animation and XOR animation are elementary techniques that are seldom
  639. used once you master frame animation and page flipping.
  640.  
  641.      As stated at the beginning of this chapter, the simple examples presented
  642. here serve as the basis for understanding the mechanics of the animation
  643. techniques we have discussed. In "real world" programs, you'll typically want
  644. to display an image using the fg_drwimage or fg_drawmap family of routines
  645. instead using rudimentary images such as the rectangles in our examples. A
  646. helpful rule is to use PCX, GIF, or pixel run files for both backgrounds and
  647. moving objects, and then use fg_getimage or fg_getmap to retrieve the moving
  648. objects as bitmapped images for later display. Of course, it's desirable to do
  649. this "behind the scenes" work on video pages other than the visual page. This  
  650.                                        Chapter 12:  Animation Techniques   285
  651.  
  652. is precisely the technique used in the Fastgraph fish tank.                    
  653. 286   Fastgraph User's Guide
  654.