


program SpriteDemo4;                { Version 2.0,  December 10,1985 }
                                    { Donald L. Pavia, Dept Chem WWU }

{----------------------------------------------------------------------------}
{$I Sprites.Lib}
{----------------------------------------------------------------------------}

var   k,l : integer;

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

begin
     TextColor (1);
     gotoxy (5,4); write ('SPRITE DESIGNER');
     TextColor (3);
     gotoxy (10,6); write ('AND');
     TextColor (1); write (' ANIMATION PACKAGE ');
     TextColor (3); write ('DEMO');
     gotoxy (1,23); write ('Donald Pavia, December 1985');

     gotoxy (1,21); write ('Action Scenes Continue Until a KeyPress');
     gotoxy (29,17);

     TextColor (2); gotoxy (30,17); write ('Ready !!! ');
     TextColor (3); read (kbd,Wait);

end; { procedure Introduction; }
{----------------------------------------------------------------------------}
procedure SaveBackGroundScreen;              { draw background screen }

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

     for k := 1 to 24 do Draw (0,8*k,319,8*k,1);

     Draw (0,0,319,0,2); Draw (319,0,319,199,2);
     Draw (319,199,0,199,2); Draw (0,199,0,0,2);

     TextColor (2);
     gotoxy  (18,8); write ('TURBO');
     gotoxy (16,18); write ('ANIMATION');
     TextColor (3);
     gotoxy (16,23); write ('Don Pavia');

     WorkBuffer := ColorBuffer;               { make a copy in workbuffer  }
     BackGroundBuffer := ColorBuffer;         { store a copy of background }

end; { procedure BackGroundScreen }
{----------------------------------------------------------------------------}
procedure CheckRegistration;

begin
     Draw (87,98,112,98,3);   Draw (112,98,112,119,3);     { check locating }
     Draw (112,119,87,119,3); Draw (87,119,87,98,3);       { algorithms     }

     Draw (119,97,144,97,3);   Draw (144,97,144,118,3);
     Draw (144,118,119,118,3); Draw (119,118,119,97,3);

     Draw (50,109,200,109,2);  Draw (100,60,100,140,2);
     Draw (132,60,132,140,2);

     gotoxy (4,5); write ('Registration Check : ');
     gotoxy (7,7); write ('Press Any Key to Continue ... ');

     read (Kbd,Wait);

end; { procedure CheckRegistration }
{----------------------------------------------------------------------------}

BEGIN
     clrscr;
     GraphColorMode; GraphBackGround (1); Palette (0);
     LoadTable ('DEMO1.TAB');
     Introduction;

REPEAT
     SaveBackGroundScreen;

    {---- Draw Diagonal Line of Whales -------------------------------------}

     Sprite := Table[14];    {Whale}          { assign sprite for display   }
                                              { print sprites in workbuffer }
     k := 24; l := 18;
     repeat XorSpriteW (k,l); k := k + 20; l := l + 12; until k >= 300;

     gotoxy (2,12); write ('  Ready !!!            Press Any Key  ');
     read (Kbd,Wait);
     ColorBuffer := WorkBuffer;                        { display workbuffer }

     FillChar (WorkBuffer,16192,0);                    { erase workbuffer   }
                                                       { to blue background }
     Delay (3000);

    {---- Demonstrate XOR --------------------------------------------------}

     XorSpriteW (100,109);   XorSpriteW (132,108);       { draw two sprites }
     ColorBuffer := WorkBuffer;                          { and display them }

     gotoxy (4,5); write ('Press Any Key to Xor Second Sprite ');
     read (Kbd,Wait);

     XorSpriteW (132,108);                     { xor second one to erase it }
     ColorBuffer := WorkBuffer;

     gotoxy (4,5); write ('Press Any Key to Redisplay It ');
     read (Kbd,Wait);

     XorSpriteW (132,108);                                     { restore it }
     ColorBuffer := WorkBuffer;

    {---- Check on Sprite Location Algorithms ------------------------------}

     Delay (1500);
     CheckRegistration;

    {---- Begin Animation Loop ---------------------------------------------}

     FillChar (WorkBuffer,16192,0);                      { erase workbuffer }
     gotoxy (2,20);
     WorkBuffer := BackGroundBuffer;                   { restore background }

     REPEAT
       k := 12; l := 20;

       repeat                                            { ANIMATION !! }

            SPRITE := Table[ 5];    XorSpriteW (k,20);         {  Duck1 }
            SPRITE := Table[14];    XorSpriteW (12,l);         {  Whale }
            SPRITE := Table[21];    XorSpriteW (k,l);          {   Boy2 }
            SPRITE := Table[22];    XorSpriteW (312-k,20);     {   Boy3 }
            SPRITE := Table[15];    XorSpriteW (312-k,80);     {   Bird }
            SPRITE := Table[ 6];    XorSpriteW (110,l);        {  Duck2 }
            SPRITE := Table[ 3];    XorSpriteW (k,120);        {   Dog2 }
            SPRITE := Table[ 2];    XorSpriteW (210,210-l);    {   Dog1 }
            SPRITE := Table[20];    XorSpriteW (160,100);      {   Boy1 }
            SPRITE := Table[ 9];    XorSpriteW (312-k,150);    { Dwarf1 }
            SPRITE := Table[17];    XorSpriteW (312-k,170);    { Dwarf2 }
            SPRITE := Table[12];    XorSpriteW (k,60);         { Dragon }

            ColorBuffer := WorkBuffer; WorkBuffer := BackGroundBuffer;
            k := k + 8;                l := l + l mod 7;

       until k >= 300;

     UNTIL KEYPRESSED;

    {-----------------------------------------------------------------------}

     gotoxy (10,10); write ('Repeat Again ? Y/N ?  ');
     repeat
          read (Kbd,Again);
     until UpCase(Again) in ['Y','N'];

UNTIL UpCase(Again) = 'N';

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

END.
