home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / grafik / sprite / demo1.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-07-18  |  5.9 KB  |  116 lines

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