{$i img20.pas}
{$i clavier2.pas}
{$m 4000,0,40000}
type
position=record
         x,y:word;
end;

type
spr=record
   pos:position;
   larg,haut,
   pagex,pagey:word;
   page:byte;
   statu:boolean;
end;

type
anim=record
   count:word;
   statu:boolean;
end;


var
sprite       :array [1..20] of spr;
count,
countb       :word;
ani          :array [1..20] of anim;
targan       :position;
nbspr,lim1,
lim2         :word;
holdvecadres :pointer;
number,vites :byte;
direction    :boolean;

{$i prinani.pas}

procedure sprites(number,page,posx,posy,px,py,larg,haut:word);
begin
 sprite[number].pos.y:=posx;
 sprite[number].pos.x:=posy;
 sprite[number].page:=page;
 sprite[number].pagex:=px;
 sprite[number].pagey:=py;
 sprite[number].larg:=larg;
 sprite[number].haut:=haut;
 sprite[number].statu:=true;
end;

procedure initvar;
begin
{decor}
 lpal('ptab1.img');
 loadimg('ptab2.img',3);
 loadimg('ptab1.img',4);
 loadimg('ptab1.img',9);
{sprites}
 nbspr:=1;
 number:=0;
 loadimg('pspr.img',1);
 loadimg('ptarspr.img',2);
 sprites(1,1,0,0,154,5,9,30);
 sprites(2,1,0,0,180,2,9,34);
 sprites(3,1,0,0,203,3,9,33);
 sprites(4,2,0,0,16,4,22,51);
 sprites(5,2,0,0,60,7,30,48);
 sprites(6,2,0,0,103,6,31,49);
 sprites(7,2,0,0,163,81,32,49);
 sprites(8,2,0,0,206,82,33,50);
 sprites(9,2,0,0,260,79,25,52);
 sprites(10,1,0,0,155,47,21,63);
 sprites(11,1,0,0,196,45,24,64);
 sprites(12,2,0,0,193,11,36,48);
 sprites(13,2,0,0,238,3,32,66);
 sprites(14,2,0,0,281,6,31,66);
 sprites(15,2,0,0,147,15,38,34);
 sprites(16,2,0,0,112,135,37,51);
 sprites(17,2,0,0,69,129,34,70);
 sprites(18,2,0,0,27,130,31,67);
 sprites(19,1,0,0,178,120,64,18);

 targan.x:=50;
 targan.y:=76;
 lim1:=10;
 lim2:=140;

{affichage}
 statu:=true;
 countb:=0;
{animation}
 for x:=1 to 20 do
 begin
 ani[x].count:=0;
 ani[x].statu:=false;
 end;

end;

{***tableau 1***}
procedure tab1;
begin
repeat
   {fond de l'ecran}
   
   decor(4);
   lightani(50,50,1,4);
   lightani(80,50,2,4);
   lightani(220,140,3,4);



   {control de tarzan}
    if keypress(75) then begin
     ani[5].statu :=true;
     ani[4].statu :=false;
    end;

   if keypress(77) then begin
    ani[4].statu :=true;
    ani[5].statu :=false;
   end;

   if (targan.x>(lim2-2)) and
      (targan.y<130) then begin
      lim1:=lim2;
      ani[6].statu :=true;
      lim2:=280;
   end;
   targanim;
    
   {affichage}
   premierplan1;
   ecran;
  until (targan.x>200);
targan.y:=0;
loadisc('ptab3.img',4);
end;

{***tableau 2***}
procedure tab2;
begin
 lim1:=15;
 lim2:=290;
repeat
   {fond de l'ecran}
   
   decor(3);
   lightani(50,60,1,4);
   lightani(230,60,2,4);

   {control de tarzan}
    if keypress(75) then begin
     ani[5].statu :=true;
     ani[4].statu :=false;
    end;

   if keypress(77) then begin
    ani[4].statu :=true;
    ani[5].statu :=false;
   end;

   if targan.y<50 then begin
   ani[6].statu:=true;
   end
   else
   ani[6].statu:=false;

   
   targanim;

   {affichage}
   premierplan2;
   ecran;
  until (targan.x>lim2-5);
inc (targan.y,5);
targan.x:=15;
end;

{***tableau 3***}
procedure tab3;
begin
 lim1:=10;
 lim2:=290;
repeat
   {fond de l'ecran}
   
   decor(4);
   lightani(92,76,1,4);
   lightani(208,76,2,4);

   if targan.x<lim1+1 then begin
   targan.x:=280;
   dec(targan.y,5);
   tab2;
   end;
   {control de tarzan}
    if keypress(75) then begin
     ani[5].statu :=true;
     ani[4].statu :=false;
    end;

   if keypress(77) then begin
    ani[4].statu :=true;
    ani[5].statu :=false;
   end;

   
   
   targanim;

   {affichage}
   premierplan3;
   ecran;
  until keypress(1);
end;

{*****PROGRAMME PRINCIPAL******}
begin
 mode(19);
 instalnewkeyb;
 clearkbd;
 initvar;
 tab1;
 tab2;
 tab3;

 delallems(0);
 holdkey;
 textmode(co80);
end.
