home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / USCX / TPSPRITE.ZIP / DEMO1.PAS < prev    next >
Pascal/Delphi Source File  |  1986-02-15  |  6KB  |  101 lines

  1.  
  2.     (* ************************************************************** *)
  3.     (*                                                                *)
  4.     (*                        SpriteDemo1.Pas                         *)
  5.     (*                                                                *)
  6.     (*   This program shows how to use sprites for multiple page      *)
  7.     (*   animation. The basic strategy is to use three pages:         *)
  8.     (*   the colorscreen, a hidden workbuffer which is a identical    *)
  9.     (*   (and may be written to unseen), and a third buffer which     *)
  10.     (*   is the part of the scene that does not change. One creates   *)
  11.     (*   the background and stores it both in backgroundbuffer and    *)
  12.     (*   in the workbuffer. Next, one writes to the workbuffer        *)
  13.     (*   ( that is, draws the sprites ).  Next the workbuffer is      *)
  14.     (*   displayed by transferring it to the colorscreen. Then one    *)
  15.     (*   erases the workbuffer by transferring the backgroundbuffer   *)
  16.     (*   to it. The now blank workscreen can again be modified,       *)
  17.     (*   displayed, and erased again ... and again ... and ...        *)
  18.     (*                                                                *)
  19.     (*   The workbuffer and the backgroundbuffer each use 16K of      *)
  20.     (*   your data segment ( 32K out of your total of 64K ). You can  *)
  21.     (*   easily reduce this to 16K if after writing the background-   *)
  22.     (*   buffer you store it in the heapspace rather than in the      *)
  23.     (*   the data segment. However, in this small program it is not   *)
  24.     (*   necessary.                                                   *)
  25.     (*                                                                *)
  26.     (*   The procedures PutSpriteC (x,y) and PutSpriteW (x,y) are     *)
  27.     (*   found in the in the include file Sprites.Lib which also      *)
  28.     (*   contains the important definitions for the program. The      *)
  29.     (*   procedure LoadTable (filename) will also be found in the     *)
  30.     (*   include file.                                                *)
  31.     (*                                                                *)
  32.     (*                            (c) Donald L. Pavia                 *)
  33.     (*                            Department of Chemistry             *)
  34.     (*     ( Ver 2.0 )            Western Washington University       *)
  35.     (*                            Bellingham, Washington  98225       *)
  36.     (*                                        February 12, 1986       *)
  37.     (*                                                                *)
  38.     (* ************************************************************** *)
  39.  
  40. program SpriteDemo1;
  41.  
  42. {----------------------------------------------------------------------------}
  43. {$I Sprites.Lib}
  44. {----------------------------------------------------------------------------}
  45.  
  46. var   i : integer;
  47.  
  48. {----------------------------------------------------------------------------}
  49.  
  50. BEGIN
  51.      clrscr;                                            { clear the deck for }
  52.      GraphColorMode; GraphBackGround (1); Palette (2);  { action and set up  }
  53.  
  54.      LoadTable ('DEMO1.TAB');                    { load the table of sprites }
  55.  
  56.    {----------------------------------------------------------------------}
  57.                     { draw background screen }
  58.  
  59.      gotoxy (5,3); write ('Three Page Animation With Sprites');
  60.  
  61.      Sprite := Table [2]; PutSpriteC  (20,50);   { draw direct to screen: }
  62.      Sprite := Table [4]; PutSpriteC  (60,50);   { this displays a number }
  63.      Sprite := Table[12]; PutSpriteC (100,50);   { of different sprites   }
  64.      Sprite := Table[14]; PutSpriteC (140,50);   { which are to become a  }
  65.      Sprite := Table[15]; PutSpriteC (180,50);   { part of the background }
  66.      Sprite := Table [3]; PutSpriteC (210,50);
  67.      Sprite := Table [5]; PutSpriteC (250,50);          { C = colorbuffer }
  68.      Sprite := Table[13]; PutSpriteC (290,50);
  69.  
  70.      draw (0,100,319,100,1); draw (319,100,319,199,1);      { box for the }
  71.      draw (319,199,0,199,1); draw (0,199,0,100,1);          { animation   }
  72.  
  73.      WorkBuffer := ColorBuffer;             { copy screen into workbuffer }
  74.      BackGroundBuffer := ColorBuffer;       { copy screen for background  }
  75.  
  76.      TextColor (2); gotoxy (25,17); write ('Press <Enter>');
  77.      read (kbd,Wait);
  78.    {-----------------------------------------------------------------------}
  79.                       { multipage animation cycles }
  80.  
  81.                                     { Table[12] and Table[13] are a dragon }
  82.      for i := 3 to 33 do begin      { Table[23] is the blast of fire       }
  83.  
  84.                                                       {     W = workbuffer }
  85.      Sprite := Table[12]; PutSpriteW (8*i,150);       { draw in workbuffer }
  86.      ColorBuffer := WorkBuffer;                       { display workbuffer }
  87.      WorkBuffer := BackGroundBuffer;                  { refresh workbuffer }
  88.  
  89.      Sprite := Table[13]; PutSpriteW (8*i,150);       { draw in workbuffer }
  90.      Sprite := Table[23]; PutSpriteW (8*i+28,150);
  91.      ColorBuffer := WorkBuffer;                       { display workbuffer }
  92.      WorkBuffer := BackGroundBuffer;                  { refresh workbuffer }
  93.  
  94.      end;
  95.    {-----------------------------------------------------------------------}
  96.  
  97.       read (Kbd,Wait); gotoxy (1,23);
  98.       TextMode (c80); clrscr;                            { exit gracefully }
  99.  
  100. END.
  101.