
    (* ************************************************************* *)
    (*                                                               *)
    (*  This program shows how to set up a relatively complicated    *)
    (*  animation sequence using multipage page-flipping techniques  *)
    (*                                                               *)
    (*                             (c) Donald L. Pavia               *)
    (*       Ver 2.0               Department of Chemistry           *)
    (*     February 1986           Western Washington University     *)
    (*                             Bellingham, Washington 98225      *)
    (*                                                               *)
    (* ************************************************************* *)


program SpriteDemo3;

{----------------------------------------------------------------------------}
{$I Sprites.Lib}
{----------------------------------------------------------------------------}
procedure Introduction;

begin
     TextColor (1);
     gotoxy  (3,5); write ('Display of Sprites and Animation');
     gotoxy  (3,7); write ('    ( multi-page techniques )');
     TextColor (3);
     gotoxy (5,21); write ('Donald Pavia, December 1985');

     LoadTable ('Demo3.tab');

     TextColor (2); gotoxy (12,15); write ('Press <ENTER> ');
     read (Kbd,Wait);
     FillChar (ColorBuffer,16383,0);

end; { procedure Introduction }
{----------------------------------------------------------------------------}

BEGIN
     clrscr;
     GraphColorMode; GraphBackGround (1); Palette (2);
     Introduction;

    {------ Draw and Save BackGround -------------------------------------}

     draw (75,25,175,25,1);   draw (175,25,175,110,1);
     draw (175,110,75,110,1); draw (75,110,75,25,1);

     TextColor (1);
     gotoxy (25,7); write ('Chemistry In');
     gotoxy (25,8); write ('  Action !  ');

     WorkBuffer := ColorBuffer;                    { copy to workbuffer }
     BackGroundBuffer := ColorBuffer;         { save a copy for refresh }
   {----------------------------------------------------------------------}

REPEAT                         { Animation Begins }
       times := 0;

   {---- Lighted Burner and Standing Flask -------------------------------}

   REPEAT
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (23,100,65); Show;
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (24,100,65); Show;
     times := times + 1;
   UNTIL times = 10; times := 0;

   {---- Test Tube is Heated ---------------------------------------------}

   REPEAT
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (2,100,48); Show;
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (2,100,48); Show; times := times + 1;
   UNTIL times = 12;  times := 0;

   {---- Boiling Begins --------------------------------------------------}

   REPEAT
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (2,100,48); Show;
     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (3,100,48); Show; times := times + 1;
   UNTIL times = 12;

   {---- Move Test Tube to Right -----------------------------------------}

   for times := 1 to 6 do begin
     Spwrite (16,148,77); Spwrite (22,100,79);
     if odd (times) then Spwrite (23,100,65) else Spwrite (24,100,65);
     Spwrite (4,116+4*times,44); Show; end;

   {---- Pour Into Flask -------------------------------------------------}

     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (5,136,57); Show;

     Spwrite (16,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (5,136,57); Show;

     Spwrite (9,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (5,136,57); Show;

     Spwrite (10,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (6,136,57); Show;

     Spwrite (11,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (7,136,57); Show;

     Spwrite (12,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (8,136,57); Show;

     Spwrite (13,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (8,136,57); Show;

     Spwrite (13,148,77); Spwrite (22,100,79); Spwrite (24,100,65);
     Spwrite (17,136,57); Show;

     Spwrite (13,148,77); Spwrite (22,100,79); Spwrite (23,100,65);
     Spwrite (1,132,57); Show; times := 0;

   {---- Reaction/Precipitation Occurs in Flask --------------------------}

   REPEAT
     Spwrite (14,148,77); Spwrite (22,100,79); Spwrite (24,100,65); Show;
     Spwrite (14,148,77); Spwrite (22,100,79); Spwrite (23,100,65); Show;
     times := times + 1;
   UNTIL times = 6; times := 0;

   REPEAT
     Spwrite (15,148,77); Spwrite (22,100,79); Spwrite (24,100,65); Show;
     Spwrite (15,148,77); Spwrite (22,100,79); Spwrite (23,100,65); Show;
     times := times + 1;
   UNTIL times = 12; times := 0;

   {---- Flame is Extinguished -------------------------------------------}

   REPEAT
     Spwrite (15,148,77); Spwrite (22,100,79); Show;
     Spwrite (15,148,77); Spwrite (22,100,79); Show; times := times + 1;
   UNTIL times = 6;

   {---- The End ---------------------------------------------------------}

     TextColor (3);
     gotoxy (8,20); write ('Repeat Again ? Y/N ?  ');

     repeat  read (Kbd,Again);  until UpCase(Again) in ['Y','N'];

     FillChar (WorkBuffer,16383,0); FillChar (ColorBuffer,16383,0);

UNTIL UpCase(Again) = 'N';

     gotoxy (1,23); TextMode (c80); clrscr;         { exit gracefully }

END.
