uses crtp2,vga2,myska,dos,zvuky;
var sprity:array[0..53] of spritetype;
    spec:array[1..12] of spritetype;
    pixely:array[1..25] of byte;
    b,c,d,e,g,h,t,pocet,kolo,penez:integer;
    typ,maxztrat,euch,uh1,uh2:byte;
    tahu,energie,cenergie:array[1..2,1..50] of shortint;
    muzesezabit:array[1..50] of byte;
    hodnoceni:integer;
    typaln:array[1..50] of byte;
    mxx,smxx,mx,my,smx,smy:word;
{    vybuch:array[1..6] of spritetype;}
    st,st2,jmeno:string[50];
    f,f2,fnast:file of byte;
    f3:file of integer;
    tx:text;
    a:longint;
    tvor:array[1..3,0..21] of spritetype;
    sprtlacitko:array[0..10] of spritetype;
    sp2,pracovni,sprlogo,sipka,nanic,nanic2,nanic3,Bnanic,sprsipka:spritetype;
    titulky:array[0..5] of spritetype;
    prac:array[2..3,1..20] of spritetype;
    Bhlasky,Bzvuky,Bdialogy,Bscrolling:boolean;
    zaklpal,plt,plt2,plt3:paltype;
    ch:char;
    xpostava,ypostava:array[1..3,1..50] of byte;
    pocetpnk,pocetaln,aktivnialn,aktivnipnk,x2,y2,x1,y1,xokolik,yokolik,xcil,ycil,rezim,uroven,maxuroven:shortint;
    hm,xtest,ytest:byte;
    zbran:array[1..2,1..20] of shortint;
    enden,povedlose,muzes,boolprac,boolprac2,vysloto,vsehotovo:boolean;
    pnk2,mb1,hmm,smb1,mb2,smb2,mbnanic,nejdeto,zkazeno:boolean;
    mapa,spesl:array[-4..101,-4..71] of byte;
    nemuze,nemuze2,nemuze3:array[-4..101,-4..71] of boolean;
    tlacitka,stlacena:array[1..5] of spritetype;
    tlacitka2,stlacena2,jetotam:spritetype;
    cesta:array[1..30] of byte;
    znak:array[1..6] of spritetype;
    zacatek:array[1..65] of byte;
    pk:array[1..50,1..17] of integer;
{      veci:array[1..11] of string[15] = ('pistolka','ostrelovacka','samopal','plamenomet','granat',
                                       'raketomet','mina','nuz','pest','kamen','lekarna');}
const ucinnost:array[1..10] of byte = ( 6, 8, 9,15,10,20, 7, 4, 2, 3);
         dosah:array[1..10] of byte = ( 4,10, 5, 3, 8, 8, 2, 1, 1, 5);
      presnost:array[1..10] of byte = ( 3, 8, 5, 7, 3, 6,10, 8,10, 2);
  akcnich_bodu:array[1..10] of byte = ( 6,10, 7, 8, 6,10, 5, 5, 4, 4);

const pr2okolik=20;
      ba:array[0..15] of byte = (0,25,34,97,108,115,139,253,20,162,194,206,240,249,251,254);
      veci:array[0..17] of string[25] = ('neozbrojen','pistolka','ostrel,','samopal','plamak','granat',
                                       'raket,','superkladivo','nuz','tyc','kamen','lekarna','10 naboju: pistolka',
                                       '5 naboju: ostrelovacka','10 naboju: samopal','10x plyn do plamenometu',
                                       '1 raketa','dynamit');
      cena:array[1..16] of integer = (1000,4500,3500,4500,500,6000,4000,500,60,60,700,150,1000,500,1000,500);

{procedure fadein(a:integer;plp:paltype);
begin
setpal(plp);
end;

procedure fadeout(a:integer;plp:paltype);
begin
setblack;
end;
 }
{procedure delay(a:integer);
begin
end;}

procedure init1(soubor:string);
begin
if Bzvuky then init(soubor);
if (soubor='sounds\fuckyou.wav') and (bzvuky=false) then delay(600);
end;

procedure play1;
begin
if Bzvuky then play;
end;



procedure tahy(post,pnk:integer);
var a,c:integer;
begin
 if hodnoceni<0 then hodnoceni:=0;
if hodnoceni>1000 then hodnoceni:=1000;
setclip (135,154,150,174);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*22);
setclip (275,154,310,174);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*22);
setclip (163,165,310,174);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*22);
setclip (0,0,319,199);
str(tahu[post,pnk],st);
print_fc(135,154,ba[15],st,false);
str(energie[post,pnk],st);
print_fc(135,164,ba[15],st,false);
str(hodnoceni div 10,st);
print_fc(275,154,ba[15],st+' +',false);
str(kolo,st);
print_fc(163,164,ba[15],st+'. kolo',false);
for a:=1 to tahu[post,pnk] do begin
    line(50+(a*2),154,50+(a*2),162,ba[14],false);
    end;
for a:=tahu[post,pnk]+1 to 40 do begin
    line(50+(a*2),154,50+(a*2),162,ba[4],false);
    end;
c:=energie[post,pnk];
for a:=1 to round((40/cenergie[post,pnk])*c) do begin
    line(50+(a*2),164,50+(a*2),172,ba[14],false);
    end;
for a:=round((40/cenergie[post,pnk])*c) to 40 do begin
    line(50+(a*2),164,50+(a*2),172,ba[4],false);
    end;
for a:=1 to round(40/100*(hodnoceni div 10)) do begin
    line(190+(a*2),154,190+(a*2),162,ba[14],false);
    end;
for a:=round(40/100*(hodnoceni div 10))to 40 do begin
    line(190+(a*2),154,190+(a*2),162,ba[4],false);
    end;
end;

{procedure vycisti(x,y:integer);
begin
  for a:=x-1 to x+1 do for b:=y-1 to y+1 do
    case mapa[b+yokolik,a+xokolik] of
    0:put(spr,a*10,b*10);
    1:put(sprvoda,a*10,b*10);
    end;

end;}

function lezivhranici(x1,y1,x2,y2:integer):boolean;
begin
if (mxx>=x1) and (mxx<=x2) and (my>=y1) and (my<=y2) then lezivhranici:=true else lezivhranici:=false;
end;

function lezelvhranici(x1,y1,x2,y2:integer):boolean;
begin
if (smxx>=x1) and (smxx<=x2) and (smy>=y1) and (smy<=y2) then lezelvhranici:=true else lezelvhranici:=false;
end;

procedure zobraz;
var a,b,c:integer;
begin
setclip(0,0,310,140);
use(virt);
loadfont('fonts\pav2.fn');
for a:=0 to 30 do for b:=0 to 13 do put_c(sprity[mapa[a+xokolik,b+yokolik]],a*10,b*10);
for a:=0 to 30 do for b:=-4 to 13 do begin
    if (spesl[a+xokolik,b+yokolik]<>0) and (spesl[a+xokolik,b+yokolik]<20)
       then putrle_c(spec[spesl[a+xokolik,b+yokolik]],a*10,b*10);
    if spesl[a+xokolik,b+yokolik]>19 then begin
       putrle_c(spec[8],a*10,b*10);
       for c:=1 to pocetpnk do if (abs(xpostava[1,c]-(a+xokolik))<5) and
           (abs(ypostava[1,c]-(b+yokolik))<5) then begin
           case spesl[a+xokolik,b+yokolik]-20 of
                1:print_fc(a*10-10,b*10+12,15,'pistolka',true);
                2:print_fc(a*10-10,b*10+12,15,'ostrel,',true);
                3:print_fc(a*10-10,b*10+12,15,'samopal',true);
                4:print_fc(a*10-10,b*10+12,15,'plamak',true);
                5:print_fc(a*10-10,b*10+12,15,'granaty',true);
                6:print_fc(a*10-10,b*10+12,15,'1000 kc',true);
                7:print_fc(a*10-10,b*10+12,15,'lekarna',true);
                8:print_fc(a*10-10,b*10+12,15,'5000 kc',true);
                9:print_fc(a*10-10,b*10+12,15,'akc, b,',true);
                0:print_fc(a*10-10,b*10+12,15,'10 hit b,',true);
                end;
           end;
       end;
    end;
for a:=1 to pocetaln do begin
     if a<>aktivnialn then begin
       if energie[2,a]<=0 then putrle_c (tvor[2,21],(xpostava[2,a]-xokolik)*10,(ypostava[2,a]-yokolik)*10+15)
          else begin
         if a=aktivnialn then
         get(prac[3,aktivnialn],(xpostava[2,aktivnialn]-xokolik)*10-20,(ypostava[2,aktivnialn]-yokolik)*10-pr2okolik,
         (xpostava[2,aktivnialn]-xokolik)*10+20,(ypostava[2,aktivnialn]-yokolik)*10+30);
            putrle_c (tvor[2,9],(xpostava[2,a]-xokolik)*10,(ypostava[2,a]-yokolik)*10);
            line ((xpostava[2,a]-xokolik)*10,(ypostava[2,a]-yokolik)*10-3,(xpostava[2,a]-xokolik)*10+10,
               (ypostava[2,a]-yokolik)*10-3,ba[10],true);
            if energie[2,a]<>cenergie[2,a] then line (round(10*(energie[2,a]/cenergie[2,a]))+
               (xpostava[2,a]-xokolik)*10,(ypostava[2,a]-yokolik)*10-3,(xpostava[2,a]-xokolik)*10+10,
               (ypostava[2,a]-yokolik)*10-3,ba[12],true);
     case typaln[a] of
          0:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'nuz',true);
          1:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'pstl',true);
          2:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'pstl',true);
          3:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'pstl',true);
          4:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'smpl',true);
          5:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'smpl',true);
          6:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'smpl',true);
          7:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'plmn',true);
          8:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'rktm',true);
          9:print_fc((xpostava[2,a]-xokolik)*10-3,(ypostava[2,a]-yokolik)*10+20,ba[7],'ostr',true);
          end;
            end;
       end;
    end;
       if energie[2,aktivnialn]<=0 then putrle_c (tvor[2,21],
          (xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10+15)
          else begin
         if aktivnialn=aktivnialn then
         get(prac[3,aktivnialn],(xpostava[2,aktivnialn]-xokolik)*10-20,(ypostava[2,aktivnialn]-yokolik)*10-pr2okolik,
         (xpostava[2,aktivnialn]-xokolik)*10+20,(ypostava[2,aktivnialn]-yokolik)*10+30);
            putrle_c (tvor[2,9],(xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10);
       line ((xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10-3,(xpostava[2,aktivnialn]-xokolik)*10+10,
               (ypostava[2,aktivnialn]-yokolik)*10-3,ba[10],true);
       if energie[2,aktivnialn]<>cenergie[2,aktivnialn] then line (round(10*(energie[2,aktivnialn]/cenergie[2,aktivnialn]))+
           (xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10-3,(xpostava[2,aktivnialn]-xokolik)*10+10,
               (ypostava[2,aktivnialn]-yokolik)*10-3,ba[12],true);
{     case typaln[aktivnialn] of
          0:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'nuz',true);
          1:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'pstl',true);
          2:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'pstl',true);
          3:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'pstl',true);
          4:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'smpl',true);
          5:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'smpl',true);
          6:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'smpl',true);
          7:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'plmn',true);
          8:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'rktm',true);
          9:print_fc((xpostava[2,aktivnialn]-xokolik)*10-3,(ypostava[2,aktivnialn]-yokolik)*10+20,ba[7],'ostr',true);
          end;}
            end;
for a:=1 to pocetpnk do if a<>aktivnipnk then begin
    if (((xpostava[1,a]-xokolik)*10-20>=-30) and ((xpostava[1,a]-xokolik)*10+20<310) and
       ((ypostava[1,a]-yokolik)*10-pr2okolik>=0) and ((ypostava[1,a]-yokolik)*10+30<140)) then
          get(prac[2,a],(xpostava[1,a]-xokolik)*10-20,(ypostava[1,a]-yokolik)*10-pr2okolik,
       (xpostava[1,a]-xokolik)*10+20,(ypostava[1,a]-yokolik)*10+30);
   {if a<>aktivnipnk then}if energie[1,a]=0 then putrle_c (tvor[1,21],(xpostava[1,a]-xokolik)*10,
       (ypostava[1,a]-yokolik)*10+15) else putrle_c (tvor[1,9],(xpostava[1,a]-xokolik)*10,(ypostava[1,a]-yokolik)*10);
    end;
       get(prac[2,aktivnipnk],(xpostava[1,aktivnipnk]-xokolik)*10-20,(ypostava[1,aktivnipnk]-yokolik)*10-pr2okolik,
       (xpostava[1,aktivnipnk]-xokolik)*10+20,(ypostava[1,aktivnipnk]-yokolik)*10+30);
   {if a<>aktivnipnk then}if energie[1,aktivnipnk]=0 then putrle_c (tvor[1,21],(xpostava[1,aktivnipnk]-xokolik)*10,
       (ypostava[1,aktivnipnk]-yokolik)*10+15) else putrle_c (tvor[1,9],(xpostava[1,aktivnipnk]-xokolik)*10,
       (ypostava[1,aktivnipnk]-yokolik)*10);

square(310,0,319,150,ba[15]);
square(0,140,319,150,ba[15]);
   get(jetotam,0,0,310,140);
   use(vga);
   put(jetotam,0,0);

     loadfont('fonts\pavel.fn');

{for a:=0 to 30 do for b:=0 to 13 do if nemuze[a+xokolik,b+yokolik] then putpixel_c (a*10+5,b*10+5,ba[15]);}
setclip(0,0,319,199);
end;

procedure jdi(smer:byte;pnk:byte;post:byte);
begin
    schovej_mysku;
    setclip(0,0,309,139);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    get(pracovni,(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-20,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+40);
    case smer of
    8:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a+12],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10-a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    ypostava[post,pnk]:=ypostava[post,pnk]-1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,13],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    2:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a+8],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10+a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    ypostava[post,pnk]:=ypostava[post,pnk]+1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,9],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    6:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a],(xpostava[post,pnk]-xokolik)*10+a*2,(ypostava[post,pnk]-yokolik)*10);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]+1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,1],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    4:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a+4],(xpostava[post,pnk]-xokolik)*10-a*2,(ypostava[post,pnk]-yokolik)*10);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]-1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,5],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    9:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a],(xpostava[post,pnk]-xokolik)*10+a*2,(ypostava[post,pnk]-yokolik)*10-a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]+1;
    ypostava[post,pnk]:=ypostava[post,pnk]-1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,1],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    7:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a+4],(xpostava[post,pnk]-xokolik)*10-a*2,(ypostava[post,pnk]-yokolik)*10-a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]-1;
    ypostava[post,pnk]:=ypostava[post,pnk]-1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,5],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    3:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a],(xpostava[post,pnk]-xokolik)*10+a*2,(ypostava[post,pnk]-yokolik)*10+a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]+1;
    ypostava[post,pnk]:=ypostava[post,pnk]+1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,1],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    1:begin
    for a:=1 to 4 do begin
    putrle_c(tvor[post,a+4],(xpostava[post,pnk]-xokolik)*10-a*2,(ypostava[post,pnk]-yokolik)*10+a*2);
    delay(30);
    put_c(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik);
    end;
    xpostava[post,pnk]:=xpostava[post,pnk]-1;
    ypostava[post,pnk]:=ypostava[post,pnk]+1;
    get(prac[post+1,pnk],(xpostava[post,pnk]-xokolik)*10-20,(ypostava[post,pnk]-yokolik)*10-pr2okolik,
       (xpostava[post,pnk]-xokolik)*10+20,(ypostava[post,pnk]-yokolik)*10+30);
    putrle_c(tvor[post,5],(xpostava[post,pnk]-xokolik)*10,(ypostava[post,pnk]-yokolik)*10);
    pnk2:=false;
    end;
    end;

if (xpostava[post,pnk]-xokolik<7) and (xokolik>0) then begin
       while (xpostava[post,pnk]-xokolik<7) and (xokolik>0) do xokolik:=xokolik-1;
       zobraz;
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
       end;
    if (xpostava[post,pnk]-xokolik>23) and (xokolik<69) then begin
       while (xpostava[post,pnk]-xokolik>23) and (xokolik<69) do xokolik:=xokolik+1;
       zobraz;
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
       end;
    if (ypostava[post,pnk]-yokolik<5) and (yokolik>0) then begin
       while (ypostava[post,pnk]-yokolik<5) and (yokolik>0) do yokolik:=yokolik-1;
       zobraz;
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
       end;
    if (ypostava[post,pnk]-yokolik>9) and (yokolik<69-13) then begin
       while (ypostava[post,pnk]-yokolik>9) and (yokolik<69-13) do yokolik:=yokolik+1;
       zobraz;
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
       end;
    tahu[post,pnk]:=tahu[post,pnk]-1;
    setclip(0,0,319,199);
    tahy(post,pnk);
    killsprite(pracovni);
    ukaz_mysku;
end;


{procedure uloz;
begin
assign(f,'Level01.lvl');
rewrite(f);
for a:=0 to 100 do for b:=0 to 70 do write(f,mapa[a,b]);
for a:=0 to 100 do for b:=0 to 70 do write(f,spesl[a,b]);
close(f);
end;}


procedure nacti(plevel:byte);
var st:string;
begin
str(plevel,st);
assign(f,'levels\Level0'+st+'.lvl');
reset(f);
for a:=0 to 100 do for b:=0 to 70 do read(f,mapa[a,b]);
for a:=0 to 100 do for b:=0 to 70 do begin
    read(f,spesl[a,b]);
    if spesl[a,b]=8 then begin
       read(f,euch);
       spesl[a,b]:=20+euch;
       end;
    end;
pocetpnk:=0;
pocetaln:=0;
for a:=0 to 100 do for b:=0 to 70 do begin
    read(f,hm);
    if hm=1 then begin
       pocetpnk:=pocetpnk+1;
       xpostava[1,pocetpnk]:=a;
       ypostava[1,pocetpnk]:=b;
       nemuze[a,b+1]:=true;
       end;
    if hm>1 then begin
       pocetaln:=pocetaln+1;
       typaln[pocetaln]:=hm-2;
       xpostava[2,pocetaln]:=a;
       ypostava[2,pocetaln]:=b;
       nemuze[a,b+1]:=true;
       end;
aktivnipnk:=1;
aktivnialn:=1;

    end;


for a:=0 to 100 do for b:=0 to 70 do nemuze[a,b]:=false;

for a:=0 to 100 do for b:=0 to 70 do begin
    if (mapa[a,b]=1) or (mapa[a,b]=34) or (mapa[a,b]=35) or (mapa[a,b]=36) or (mapa[a,b]=37) or (mapa[a,b]=17)
       or (mapa[a,b]=18) or (mapa[a,b]=22) or (mapa[a,b]=23) or (mapa[a,b]=24) or (mapa[a,b]=45) or (mapa[a,b]=46)
       or (mapa[a,b]=47) or (mapa[a,b]=48) or (mapa[a,b]=49) or (mapa[a,b]=50) or (mapa[a,b]=51) or (mapa[a,b]=52)
       then nemuze[a,b]:=true;
    if spesl[a,b]=1 then begin
       nemuze[a,b]:=true;
       nemuze[a+1,b]:=true;
       nemuze[a+1,b+1]:=true;
       nemuze[a+1,b+2]:=true;
       nemuze[a,b+1]:=true;
       nemuze[a,b+2]:=true;
       end;
    if spesl[a,b]=2 then begin
       nemuze[a+1,b]:=true;
       nemuze[a+1,b+1]:=true;
       nemuze[a+1,b+2]:=true;
       nemuze[a,b+1]:=true;
       nemuze[a,b+2]:=true;
       end;
    if spesl[a,b]=3 then begin
       nemuze[a+1,b]:=true;
       nemuze[a+1,b+1]:=true;
       nemuze[a+1,b+2]:=true;
       nemuze[a+1,b+3]:=true;
       nemuze[a,b+1]:=true;
       nemuze[a,b+2]:=true;
       nemuze[a,b+3]:=true;
       end;
    if spesl[a,b]=5 then begin
       nemuze[a,b]:=true;
       nemuze[a+2,b]:=true;
       nemuze[a+3,b]:=true;
       nemuze[a,b+1]:=true;
       nemuze[a+1,b+1]:=true;
       nemuze[a+2,b+1]:=true;
       nemuze[a+3,b+1]:=true;
       nemuze[a,b+2]:=true;
       nemuze[a+1,b+2]:=true;
       nemuze[a+2,b+2]:=true;
       nemuze[a+3,b+2]:=true;
       nemuze[a,b+3]:=true;
       nemuze[a+1,b+3]:=true;
       nemuze[a+2,b+3]:=true;
       end;
    if spesl[a,b]=9 then begin
       nemuze[a,b]:=true;
       nemuze[a+1,b]:=true;
       nemuze[a,b+1]:=true;
       end;
    if spesl[a,b]=11 then begin
       nemuze[a,b]:=true;
       end;
    if (spesl[a,b]=10) or (spesl[a,b]=12) then begin
       nemuze[a,b]:=true;
       nemuze[a,b+1]:=true;
       end;
    end;
for a:=1 to pocetaln do begin
case typaln[a] of
     0:zbran[2,a]:=8;
     1:zbran[2,a]:=1;
     2:zbran[2,a]:=1;
     3:zbran[2,a]:=1;
     4:zbran[2,a]:=3;
     5:zbran[2,a]:=3;
     6:zbran[2,a]:=3;
     7:zbran[2,a]:=4;
     8:zbran[2,a]:=6;
     9:zbran[2,a]:=2;
     end;

end;
close(f);
end;
function kontrola8(post,jaka:byte):boolean;
begin
   if (nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])]) then kontrola8:=true else kontrola8:=false;
end;
function kontrola2(post,jaka:byte):boolean;
begin
   if (nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])+2]) then kontrola2:=true else kontrola2:=false;
end;
function kontrola6(post,jaka:byte):boolean;
begin
   if (nemuze[(xpostava[post,jaka])+1,(ypostava[post,jaka])+1]) then kontrola6:=true else kontrola6:=false;
end;
function kontrola4(post,jaka:byte):boolean;
begin
   if (nemuze[(xpostava[post,jaka])-1,(ypostava[post,jaka])+1]) then kontrola4:=true else kontrola4:=false;
end;
function kontrola9(post,jaka:byte):boolean;
var prac:boolean;
begin
   prac:=true;
   if (nemuze[(xpostava[post,jaka])+1,(ypostava[post,jaka])]) then begin
      if nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])]=false then begin
         a:=8;
         prac:=false;
         end;
      if nemuze[(xpostava[post,jaka])+1,(ypostava[post,jaka])+1]=false then begin
         a:=6;
         prac:=false;
         end;
      end else prac:=false;
   kontrola9:=prac;
end;
function kontrola7(post,jaka:byte):boolean;
var prac:boolean;
begin
      prac:=true;
   if (nemuze[(xpostava[post,jaka])-1,(ypostava[post,jaka])]) then begin
      if nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])-1]=false then begin
         a:=8;
         prac:=false;
         end;
      if nemuze[(xpostava[post,jaka])-1,(ypostava[post,jaka])]=false then begin
         a:=4;
         prac:=false;
         end;
      end else prac:=false;
   kontrola7:=prac;
end;
function kontrola3(post,jaka:byte):boolean;
var prac:boolean;
begin
      prac:=true;
   if (nemuze[(xpostava[post,jaka])+1,(ypostava[post,jaka])+2]) then begin
      if nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])+2]=false then begin
         a:=2;
         prac:=false;
         end;
      if nemuze[(xpostava[post,jaka])+1,(ypostava[post,jaka])+1]=false then begin
         a:=6;
         prac:=false;
         end;
      end else prac:=false;
   kontrola3:=prac;
end;
function kontrola1(post,jaka:byte):boolean;
var prac:boolean;
begin
      prac:=true;
   if (nemuze[(xpostava[post,jaka])-1,(ypostava[post,jaka])+2]) then begin
      if nemuze[(xpostava[post,jaka]),(ypostava[post,jaka])+2]=false then begin
         a:=2;
         prac:=false;
         end;
      if nemuze[(xpostava[post,jaka])-1,(ypostava[post,jaka])+1]=false then begin
         a:=4;
         prac:=false;
         end;
      end else prac:=false;
   kontrola1:=prac;
end;

procedure tlac(x1,y1:integer);
var x2,y2,a,b:integer;
begin
x2:=x1+15;
y2:=y1+12;
{box(x1,y1,x2,y2,ba[7]);}
setclip(x1,y1,x2,y2);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*21);
setclip(0,0,319,199);
square(x1,y1,x2,y2,ba[7]);
square(x1+1,y1+1,x2-1,y2-1,ba[0]);
end;

procedure stlac(x1,y1:integer);
var x2,y2,a,b:integer;
begin
x2:=x1+15;
y2:=y1+12;
{box(x1,y1,x2,y2,ba[7]);}
setclip(x1,y1,x2,y2);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22+1,150+b*21+1);
setclip(0,0,319,199);
square(x1,y1,x2,y2,ba[8]);
square(x1+1,y1+1,x2-1,y2-1,ba[0]);
end;

procedure tlac2(x1,y1:integer);
var x2,y2,a,b:integer;
begin
x2:=x1+34;
y2:=y1+12;
{box(x1,y1,x2,y2,ba[7]);}
setclip(x1,y1,x2,y2);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*21);
setclip(0,0,319,199);
square(x1,y1,x2,y2,ba[7]);
square(x1+1,y1+1,x2-1,y2-1,ba[0]);
end;

procedure stlac2(x1,y1:integer);
var x2,y2,a,b:integer;
begin
x2:=x1+34;
y2:=y1+12;
{box(x1,y1,x2,y2,ba[7]);  }
setclip(x1,y1,x2,y2);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22+1,150+b*21+1);
setclip(0,0,319,199);
square(x1,y1,x2,y2,ba[8]);
square(x1+1,y1+1,x2-1,y2-1,ba[0]);
end;
procedure rekni(co:byte);
begin
 if Bhlasky then begin
 str(co,st);
 init1('sounds\hl'+st+'.wav');
 play1;
 boolprac:=true;
 boolprac2:=true;
 delay(200);
 end;
end;

procedure zbrane(tvor:integer);
begin

loadfont('fonts\pav2.fn');
    box(116,180,183,192,ba[8]);
    if tvor=1 then st:=chr(zbran[1,aktivnipnk]+64) else st:=chr(zbran[2,aktivnialn]+64);
    print_fc(119,180,ba[14],st,false);
    if tvor=1 then print_fc(135,183,ba[15],veci[zbran[tvor,aktivnipnk]],false) else
       print_fc(135,183,ba[15],veci[zbran[tvor,aktivnialn]],false);
    if (tvor=1) and (zbran[tvor,aktivnipnk]<>8) and (zbran[tvor,aktivnipnk]<>9)
       and (pk[aktivnipnk,zbran[tvor,aktivnipnk]]>0) then begin
       str(pk[aktivnipnk,zbran[tvor,aktivnipnk]],st);
       print_fc(173,183,15,st,false);
       end;
loadfont('fonts\pavel.fn');
end;


procedure zmenpanaka;
begin
              schovej_mysku;
              a:=xpostava[1,aktivnipnk]-15;
              ycil:=ypostava[1,aktivnipnk]-7;
              if a<0 then a:=0;
              if ycil<0 then ycil:=0;
              if a>69 then a:=69;
              if ycil>56 then ycil:=56;
                tahy(1,aktivnipnk);
              while (xokolik<>a) or (yokolik<>ycil) do begin
                 if a>xokolik then xokolik:=xokolik+1;
                 if a<xokolik then xokolik:=xokolik-1;
                 if ycil>yokolik then yokolik:=yokolik+1;
                 if ycil<yokolik then yokolik:=yokolik-1;
                 zobraz;
                 box(11,141,299,149,248);
                 box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
                 box(311,11,319,130,248);
                 box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
                 delay(10);
                 end;
                    get(nanic,(xpostava[1,aktivnipnk]-xokolik)*10,(ypostava[1,aktivnipnk]-yokolik)*10-10,
                     (xpostava[1,aktivnipnk]-xokolik)*10+10,(ypostava[1,aktivnipnk]-yokolik)*10);
                for a:=1 to 3 do begin
                    putrle(sprsipka,(xpostava[1,aktivnipnk]-xokolik)*10+1,(ypostava[1,aktivnipnk]-yokolik)*10-10);
                    delay(90);
                    put(nanic,(xpostava[1,aktivnipnk]-xokolik)*10,(ypostava[1,aktivnipnk]-yokolik)*10-10);
                    delay(90);
                    end;
                zbrane(1);
                ukaz_mysku;

end;
procedure souradnice(x,y:integer;klavesa:boolean);
begin
              x:=x-15;
              y:=y-7;
              if x<0 then x:=0;
              if y<0 then y:=0;
              if x>69 then x:=69;
              if y>56 then y:=56;
              while ((xokolik<>x) or (yokolik<>y)) and ((klavesa=false) or (keypressed=false)) do begin
                 if x>xokolik then xokolik:=xokolik+1;
                 if x<xokolik then xokolik:=xokolik-1;
                 if y>yokolik then yokolik:=yokolik+1;
                 if y<yokolik then yokolik:=yokolik-1;
                 zobraz;
                 box(11,141,299,149,248);
                 box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
                 box(311,11,319,130,248);
                 box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
                 delay(20);
                 end;
end;
procedure zmenaliena(x:integer);
begin
              schovej_mysku;
              a:=xpostava[2,x]-15;
              ycil:=ypostava[2,x]-7;
              if a<0 then a:=0;
              if ycil<0 then ycil:=0;
              if a>69 then a:=69;
              if ycil>56 then ycil:=56;
                tahy(2,aktivnialn);
                while (xokolik<>a) or (yokolik<>ycil) do begin
                if a>xokolik then xokolik:=xokolik+1;
                if a<xokolik then xokolik:=xokolik-1;
                if ycil>yokolik then yokolik:=yokolik+1;
                if ycil<yokolik then yokolik:=yokolik-1;
                zobraz;
                box(11,141,299,149,248);
                box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
                box(311,11,319,130,248);
                box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
                delay(10);
                end;
                ukaz_mysku;
end;
function vyzkousej(xpr,ypr,poc:byte):byte;
var a,b,c,poce,xproc,yproc:byte;


begin

for a:=1 to 30 do cesta[a]:=0;
{ Priblizeni }
xproc:=xpr;
yproc:=ypr;
poce:=0;
repeat
nemuze[xproc,yproc+1]:=true;
enden:=false;
{if (xproc=x2) and (yproc=y2) then boolprac:=true;}

if (enden=false) and (x2>xproc) and (y2<yproc) and (nemuze[xproc+1,yproc]=false)
    then begin
         cesta[poce]:=9;
         xproc:=xproc+1;
         yproc:=yproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2>xproc) and (y2>yproc) and (nemuze[xproc+1,yproc+2]=false)
    then begin
         cesta[poce]:=3;
         xproc:=xproc+1;
         yproc:=yproc+1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2<yproc) and (nemuze[xproc-1,yproc]=false)
    then begin
         cesta[poce]:=7;
         xproc:=xproc-1;
         yproc:=yproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2>yproc) and (nemuze[xproc-1,yproc+2]=false)
    then begin
         cesta[poce]:=1;
         xproc:=xproc-1;
         yproc:=yproc+1;
         enden:=true;
         end;

 if (enden=false) and (x2>xproc) and (nemuze[xproc+1,yproc+1]=false) then begin
         cesta[poce]:=6;
         xproc:=xproc+1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (nemuze[xproc-1,yproc+1]=false) then begin
         cesta[poce]:=4;
         xproc:=xproc-1;
         enden:=true;
         end;
 if (enden=false) and (y2>yproc) and (nemuze[xproc,yproc+2]=false) then begin
         cesta[poce]:=2;
         yproc:=yproc+1;
         enden:=true;
         end;
 if (enden=false) and (y2<yproc) and (nemuze[xproc,yproc]=false) then begin
         cesta[poce]:=8;
         yproc:=yproc-1;
         enden:=true;
         end;

{ Nevzdaleni}

 if (enden=false) and (((x2=xproc) and (y2<yproc+1)) or ((x2>xproc)
    and (y2=yproc+1))) and (nemuze[xproc+1,yproc]=false)
    then begin
         cesta[poce]:=9;
         xproc:=xproc+1;
         yproc:=yproc-1;
         enden:=true;
         end;
 if (enden=false) and (((x2=xproc) and (y2>yproc)) or ((x2>xproc)
    and (y2=yproc+1))) and (nemuze[xproc+1,yproc+2]=false)
    then begin
         cesta[poce]:=3;
         xproc:=xproc+1;
         yproc:=yproc+1;
         enden:=true;
         end;
 if (enden=false) and (((x2=xproc) and (y2<yproc)) or ((x2<xproc)
    and (y2=yproc+1))) and (nemuze[xproc-1,yproc]=false)
    then begin
         cesta[poce]:=7;
         xproc:=xproc+1;
         yproc:=yproc+1;
         enden:=true;
         end;
 if (enden=false) and (((x2=xproc) and (y2>yproc)) or ((x2<xproc)
    and (y2=yproc+1))) and (nemuze[xproc-1,yproc+2]=false)
    then begin
         cesta[poce]:=1;
         xproc:=xproc-1;
         yproc:=yproc+1;
         enden:=true;
         end;

 if (enden=false) and (x2>xproc) and (y2<yproc+1) and (nemuze[xproc+1,yproc]=false)
    then begin
         cesta[poce]:=8;
         yproc:=yproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2>xproc) and (y2<yproc+1) and (nemuze[xproc+1,yproc]=false)
    then begin
         cesta[poce]:=6;
         xproc:=xproc+1;
         enden:=true;
         end;
 if (enden=false) and (x2>xproc) and (y2>yproc+1) and (nemuze[xproc+1,yproc+2]=false)
    then begin
         cesta[poce]:=6;
         xproc:=xproc+1;
         enden:=true;
         end;
 if (enden=false) and (x2>xproc) and (y2>yproc+1) and (nemuze[xproc+1,yproc+2]=false)
    then begin
         cesta[poce]:=2;
         yproc:=yproc+1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2<yproc+1) and (nemuze[xproc-1,yproc]=false)
    then begin
         cesta[poce]:=8;
         yproc:=yproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2<yproc+1) and (nemuze[xproc-1,yproc]=false)
    then begin
         cesta[poce]:=4;
         xproc:=xproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2>yproc+1) and (nemuze[xproc-1,yproc+2]=false)
    then begin
         cesta[poce]:=4;
         xproc:=xproc-1;
         enden:=true;
         end;
 if (enden=false) and (x2<xproc) and (y2>yproc+1) and (nemuze[xproc-1,yproc+2]=false)
    then begin
         cesta[poce]:=2;
         yproc:=yproc+1;
         enden:=true;
         end;
 poce:=poce+1;
until ((xproc=x2) and (yproc=y2)) or (poce>25) or (enden=false);

 { Vzdaleni }

(*if enden=false then begin
  b:=0;
  if (nemuze[xproc,yproc-1]=false) then begin
{     for g:=-4 to 101 do for h:=-4 to 71 do nemuze3[g,h]:=nemuze[g,h];}
     c:=vyzkousej(xproc,yproc-1,50);
     nemuze:=nemuze3;
{     for g:=-4 to 101 do for h:=-4 to 71 do nemuze[g,h]:=nemuze3[g,h];}
     a:=8;
     b:=c;
     end;
  if (nemuze[xproc+1,yproc]=false) then begin
     c:=vyzkousej(xproc+1,yproc,50);
     nemuze:=nemuze3;
     if c>b then begin
        a:=6;
        b:=c;
        end;
     end;
  if (nemuze[xproc-1,yproc]=false) then begin
     c:=vyzkousej(xproc-1,yproc,50);
     nemuze:=nemuze3;
     if c>b then begin
        a:=4;
        b:=c;
        end;
     end;
  if (nemuze[xproc,yproc+1]=false) then begin
     c:=vyzkousej(xproc,yproc+1,50);
     nemuze:=nemuze3;
     if c>b then begin
        a:=2;
        b:=c+poce-50;
        end;
     end;
     cesta[poce]:=a;
     case a of
     2:c:=vyzkousej(xproc,yproc+1,poce);
     8:c:=vyzkousej(xproc,yproc-1,poce);
     6:c:=vyzkousej(xproc+1,yproc,poce);
     4:c:=vyzkousej(xproc-1,yproc,poce);
     end;
  end;   *)
if enden=false then poce:=50;
vyzkousej:=poce;
end;

procedure ukaz_kurzor;
begin
   x1:=(mx div 20);
   y1:=(my div 10);
   x2:=(smx div 20);
   y2:=(smy div 10);
   put_c(sipka,x2*10,y2*10);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
   if rezim=1 then square(x1*10,y1*10,x1*10+10,y1*10+10,ba[7]) else begin
      line(x1*10+1,y1*10+1,x1*10+9,y1*10+9,ba[12],false);
      line(x1*10+9,y1*10+1,x1*10+1,y1*10+9,ba[12],false);
      end;
end;

procedure line2(xx,yy,xx2,yy2,p:integer;var xxx,yyy:integer);
var a,b,c:integer;
    x,y,x2,y2:integer;
begin
x:=xx;
y:=yy;
x2:=xx2;
y2:=yy2;
c:=x2-x;
b:=y2-y;
xxx:=round(c*(p/100))+x;
yyy:=round(b*(p/100))+y;
end;

function kontrola100(x,y,x2,y2,proc:integer):boolean;
var a,c,d:integer;
    xx,yy,xx2,yy2:integer;
    bl:boolean;
begin
  bl:=false;
  xx:=(x-xokolik)*10+5;
  yy:=(y-yokolik)*10+10;
  xx2:=(x2-xokolik)*10+5;
  yy2:=(y2-yokolik)*10+15;
  nemuze2:=nemuze;
  for a:=1 to pocetpnk do nemuze[xpostava[1,a],ypostava[1,a]+1]:=false;
  for a:=1 to pocetaln do nemuze[xpostava[2,a],ypostava[2,a]+1]:=false;
      a:=proc;
      line2(xx,yy,xx2,yy2,a,c,d);
      if nemuze[round((c-5)/10)+xokolik,round((d-5)/10)+yokolik] then bl:=true else bl:=false;
{          square(round((c-5)/10)*10,round((d-5)/10)*10,round((c-5)/10)*10+10,round((d-5)/10)*10+10,ba[12]);}
  nemuze:=nemuze2;
  if bl=true then kontrola100:=false else kontrola100:=true;
end;


function kontrola(x,y,x2,y2:integer):boolean;
var a,c,d:integer;
    xx,yy,xx2,yy2:integer;
    bl:boolean;
begin
{  bl:=false;
  for a:=1 to 100 do begin
      if kontrola100(x,y,x2,y2,a)=false then bl:=true;
      end;
  if bl then kontrola:=false else kontrola:=true;}
for a:=0 to 100 do for b:=0 to 70 do
    if (mapa[a,b]=1) or (mapa[a,b]=34) or (mapa[a,b]=35) or (mapa[a,b]=36) or (mapa[a,b]=37) or (mapa[a,b]=17)
       or (mapa[a,b]=18) or (mapa[a,b]=22) or (mapa[a,b]=23) or (mapa[a,b]=24)
       then nemuze[a,b]:=false;
  bl:=false;
  xx:=(x-xokolik)*10+5;
  yy:=(y-yokolik)*10+10;
  xx2:=(x2-xokolik)*10+5;
  yy2:=(y2-yokolik)*10+15;
  nemuze2:=nemuze;
  for a:=1 to pocetpnk do nemuze[xpostava[1,a],ypostava[1,a]+1]:=false;
  for a:=1 to pocetaln do nemuze[xpostava[2,a],ypostava[2,a]+1]:=false;
  for a:=1 to 100 do begin
      line2(xx,yy,xx2,yy2,a,c,d);
      if nemuze[round((c-5)/10)+xokolik,round((d-5)/10)+yokolik] then bl:=true;
  end;
  nemuze:=nemuze2;
{  for a:=1 to pocetpnk do nemuze[xpostava[1,a],ypostava[1,a]+1]:=true;
  for a:=1 to pocetaln do nemuze[xpostava[2,a],ypostava[2,a]+1]:=true;}
  if bl=true then kontrola:=false else kontrola:=true;
for a:=0 to 100 do for b:=0 to 70 do
    if (mapa[a,b]=1) or (mapa[a,b]=34) or (mapa[a,b]=35) or (mapa[a,b]=36) or (mapa[a,b]=37) or (mapa[a,b]=17)
       or (mapa[a,b]=18) or (mapa[a,b]=22) or (mapa[a,b]=23) or (mapa[a,b]=24)
       then nemuze[a,b]:=true;

end;


procedure strela(tvr,cislotvora:byte);
var a,b,c,d,e,h:integer;
    trefa:boolean;
begin
      a:=abs(xpostava[tvr,cislotvora]-x2);
      b:=abs(ypostava[tvr,cislotvora]-y2);
      g:=a;
      h:=b;
      if Bhlasky then begin
      c:=random(11)+1;
      if c=11 then c:=23;
      rekni(c);
      boolprac:=false;
      if bdialogy then begin
      repeat
      boolprac2:=false;
      if (c=6) and (random(2)=1) then begin
         c:=8;
         rekni(c);
         end;
      if ((c=7) or (c=7)) and (random(2)=1) then begin
         c:=16;
         rekni(c);
         end;
      if (c=10) or (c=13) then begin
         d:=random(3);
         if d=1 then c:=23;
         if d=2 then c:=14;
         if d<>0 then rekni(c);
         end;
      if (c=14) and (random(2)=1) then begin
         c:=22;
         rekni(c);
         end;
      if (c=16) then begin
         d:=random(3);
         if d=1 then c:=22;
         if d=2 then c:=14;
         if d<>0 then rekni(c);
         end;
      if (c=22) and (random(2)=1) then begin
         c:=6;
         rekni(c);
         end;
      boolprac:=boolprac2;
      until boolprac=false;
      end;
      end;
      delay(200);
      setclip(0,0,309,139);
      if (tvr=1) then begin
      put_c(sipka,(mx div 20)*10,(my div 10)*10);
      end;
      zobraz;
      setclip(0,0,309,139);
      put_c(prac[1+tvr,cislotvora],(xpostava[tvr,cislotvora]-xokolik)*10-20,(ypostava[tvr,cislotvora]-yokolik)*10-pr2okolik);
      if a>b then begin
         if x2>xpostava[tvr,cislotvora] then
            putrle_c (tvor[tvr,17],(xpostava[tvr,cislotvora]-xokolik)*10,(ypostava[tvr,cislotvora]-yokolik)*10)
            else putrle_c (tvor[tvr,18],(xpostava[tvr,cislotvora]-xokolik)*10,(ypostava[tvr,cislotvora]-yokolik)*10)
         end else begin
           if y2>ypostava[tvr,cislotvora] then
              putrle_c (tvor[tvr,19],(xpostava[tvr,cislotvora]-xokolik)*10,(ypostava[tvr,cislotvora]-yokolik)*10)
              else putrle_c (tvor[tvr,20],(xpostava[tvr,cislotvora]-xokolik)*10,(ypostava[tvr,cislotvora]-yokolik)*10);
           end;
if tvr=2 then begin
for a:=1 to pocetpnk do begin
    if (((xpostava[1,a]-xokolik)*10-20>=0) and ((xpostava[1,a]-xokolik)*10+20<310) and
       ((ypostava[1,a]-yokolik)*10-pr2okolik>=0) and ((ypostava[1,a]-yokolik)*10+30<140)) then
          get(prac[2,a],(xpostava[1,a]-xokolik)*10-20,(ypostava[1,a]-yokolik)*10-pr2okolik,
       (xpostava[1,a]-xokolik)*10+20,(ypostava[1,a]-yokolik)*10+30);
   {if a<>aktivnipnk then}if energie[1,a]=0 then putrle_c (tvor[1,21],(xpostava[1,a]-xokolik)*10,
       (ypostava[1,a]-yokolik)*10+15) else putrle_c (tvor[1,9],(xpostava[1,a]-xokolik)*10,(ypostava[1,a]-yokolik)*10);
    end;
end;
           case zbran[tvr,cislotvora] of
              1:init1('sounds\pistolka.wav');
              2:init1('sounds\ostrel.wav');
              3:init1('sounds\samopal.wav');
              4:init1('sounds\plamak.wav');
              5:init1('sounds\kamen.wav');
              6:init1('sounds\raketa.wav');
              7:init1('sounds\pest.wav');
              8:init1('sounds\nuz.wav');
              9:init1('sounds\pest.wav');
              10:init1('sounds\kamen.wav');
              end;
              h:=zbran[tvr,cislotvora];
              play1;
             tahu[tvr,cislotvora]:=tahu[tvr,cislotvora]-akcnich_bodu[zbran[tvr,cislotvora]];
             if (tvr=1) and (zbran[1,cislotvora]<>8) and (zbran[1,cislotvora]<>9) and (zbran[1,cislotvora]<>7)
                then pk[cislotvora,zbran[1,cislotvora]]:= pk[cislotvora,zbran[1,cislotvora]]-1;
             tahy(tvr,cislotvora);
             if pk[cislotvora,zbran[1,cislotvora]]=0 then begin
                zbran[1,cislotvora]:=0;
                repeat zbran[1,cislotvora]:=zbran[1,cislotvora]+1 until (pk[cislotvora,zbran[1,cislotvora]]>0)
                       or (zbran[1,cislotvora]>=20);
                if zbran[1,cislotvora]>=20 then zbran[1,cislotvora]:=0;
                end;
             zbrane(1);
      trefa:=true;
for a:=0 to 100 do for b:=0 to 70 do
    if (mapa[a,b]=1) or (mapa[a,b]=34) or (mapa[a,b]=35) or (mapa[a,b]=36) or (mapa[a,b]=37) or (mapa[a,b]=17)
       or (mapa[a,b]=18) or (mapa[a,b]=22) or (mapa[a,b]=23) or (mapa[a,b]=24)
       then nemuze[a,b]:=false;
      for a:=20 to 100 do begin
          line2((xpostava[tvr,cislotvora]-xokolik)*10+5,(ypostava[tvr,cislotvora]-yokolik)*10+10,
              (x2-xokolik)*10+5,(y2-yokolik)*10+15,a,c,d);
          e:=getpixel(c,d);
          putpixel_c(c,d,ba[15]);
          delay(3);
          putpixel_c(c,d,e);
          if kontrola100(xpostava[tvr,cislotvora],ypostava[tvr,cislotvora],x2,y2,a)=false then begin
             a:=100;
             trefa:=false;
             end;
{          square(round((c-5)/10)*10,round((d-5)/10)*10,round((c-5)/10)*10+10,round((d-5)/10)*10+10,ba[12]);}
          end;
           case {zbran[tvr,cislotvora]}h of
              5,6:begin
                init1('sounds\granat.wav');
                play1;
                end;
              end;
for a:=0 to 100 do for b:=0 to 70 do
    if (mapa[a,b]=1) or (mapa[a,b]=34) or (mapa[a,b]=35) or (mapa[a,b]=36) or (mapa[a,b]=37) or (mapa[a,b]=17)
       or (mapa[a,b]=18) or (mapa[a,b]=22) or (mapa[a,b]=23) or (mapa[a,b]=24)
       then nemuze[a,b]:=true;
{          zobraz;}
      if trefa=true then begin
      if tvr=1 then d:=pocetaln else d:=pocetpnk;
      for a:=1 to d do begin
          if (xpostava[3-tvr,a]=x2) and ((ypostava[3-tvr,a]=y2) or (ypostava[3-tvr,a]-1=y2)) and (energie[3-tvr,a]>0)
             then begin
             c:=0;
             c:=c+((ucinnost[zbran[tvr,cislotvora]]*3)-round((random(round((g+h)/2)+random(4))*
                ((8-presnost[zbran[tvr,cislotvora]])/3)+1)*1.5));
             if c=1 then c:=2;
             energie[3-tvr,a]:=energie[3-tvr,a]-c;
             if 3-tvr=1 then hodnoceni:=hodnoceni-round((c*((c+8)/8))/5+1);
             if 3-tvr=2 then hodnoceni:=hodnoceni+round((c*((c+8)/8))/5+1);
             if energie[3-tvr,a]<0 then energie[3-tvr,a]:=0;
             line ((xpostava[3-tvr,a]-xokolik)*10,(ypostava[3-tvr,a]-yokolik)*10-3,(xpostava[3-tvr,a]-xokolik)*10+10,
               (ypostava[3-tvr,a]-yokolik)*10-3,ba[10],true);
             if energie[3-tvr,a]<>cenergie[3-tvr,a] then line (round(10*(energie[3-tvr,a]/cenergie[3-tvr,a]))+
               (xpostava[3-tvr,a]-xokolik)*10,(ypostava[3-tvr,a]-yokolik)*10-3,(xpostava[3-tvr,a]-xokolik)*10+10,
               (ypostava[3-tvr,a]-yokolik)*10-3,ba[12],true);
             tahy(tvr,cislotvora);
             loadfont('fonts\pav2.fn');
             get(nanic,(xpostava[3-tvr,a]-xokolik)*10-5,(ypostava[3-tvr,a]-yokolik)*10+20,
                (xpostava[3-tvr,a]-xokolik)*10+17,(ypostava[3-tvr,a]-yokolik)*10+25);
             str(c,st);
{                (xpostava[1,aktivnipnk]-xokolik)*10+20,(ypostava[1,aktivnipnk]-yokolik)*10+30);}
             box((xpostava[3-tvr,a]-xokolik)*10-4,(ypostava[3-tvr,a]-yokolik)*10+20,
                 (xpostava[3-tvr,a]-xokolik)*10+17{-round((length(st)+1)*1.5)},(ypostava[3-tvr,a]-yokolik)*10+25,60);
             print_fc((xpostava[3-tvr,a]-xokolik)*10+5-round((length(st)+1)*1.5),
                     (ypostava[3-tvr,a]-yokolik)*10+20,ba[15],'-'+st,false);
      if Bhlasky then begin
      c:=random(11)+11;
      while (c=16) or (c=15) or (c=19) do c:=random(11)+11;
      if energie[3-tvr,a]=0 then begin
         c:=random(2);
         if c=1 then c:=15 else c:=19;
         end;
      rekni(c);
      end;
      if bhlasky=false then delay(500);
             put(nanic,(xpostava[3-tvr,a]-xokolik)*10-5,(ypostava[3-tvr,a]-yokolik)*10+20);
             loadfont('fonts\pavel.fn');

             if energie[3-tvr,a]<=0 then begin
{                put(prac[1+tvr,a],(xpostava[3-tvr,a]-xokolik)*10-20,(ypostava[3-tvr,a]-yokolik)*10-pr2okolik);
                putrle_c (tvor[3-tvr,21],(xpostava[3-tvr,a]-xokolik)*10,(ypostava[3-tvr,a]-yokolik)*10+15);}
                zobraz;
                get(sipka,(mx div 20)*10,(my div 10)*10,(mx div 20)*10+10,(my div 10)*10+10);
                nemuze[xpostava[3-tvr,a],ypostava[3-tvr,a]+1]:=false;
                if 3-tvr=1 then hodnoceni:=hodnoceni-round(300/pocetpnk) else hodnoceni:=hodnoceni+round(400/pocetaln);
                tahy(tvr,cislotvora);
                end;
end;
end;
     end else begin
         init1('sounds\vedle.wav');
         play1;
         end;
       if tvr=1 then ukaz_kurzor;
end;

procedure zkaz_misi;
var a:integer;
begin
if zkazeno=false then begin
               fuckit;
{              getpal(plt);
               fadeout(4,plt);}

               zkazeno:=true;
end;
end;

procedure spln_misi;
var a,b:integer;
    st,st2:string;
begin
if zkazeno=false then begin
               schovej_mysku;
               print_fc(121,71,ba[0],'Mise spln@na.',false);
               print_fc(119,69,ba[0],'Mise spln@na.',false);
               print_fc(121,69,ba[0],'Mise spln@na.',false);
               print_fc(119,71,ba[0],'Mise spln@na.',false);
               print_fc(120,70,ba[14],'Mise spln@na.',false);
               init1('sounds\hl12.wav');
               play1;
               for a:=0 to 100 do begin
                   line (0,a,319,a,0,false);
                   line (0,199-a,319,199-a,0,false);
                   print_fc(120,70,ba[14],'Mise spln@na.',false);
                   delay(20);
                   end;
               readkey;
               fadeout(4,plt2);
               cls(0);
               setblack;
               use(virt);
               loadpcx(0,0,'images\splneno.obr');
               b:=0;
               for a:=1 to pocetpnk do if energie[1,a]<=0 then b:=b+1;
               str(b,st);
               str(pocetpnk,st2);
               print_fc(40,61,255,'Zabit&ch bojovn(k": '+st+' z '+st2,false);
               b:=0;
               for a:=1 to pocetaln do if energie[2,a]<=0 then b:=b+1;
               str(b,st);
               str(pocetaln,st2);
               print_fc(40,71,255,'Zabit&ch alien": '+st+' z '+st2,false);
               str(hodnoceni div 10,st);
               print_fc(40,81,255,'Tvoje reputace <Hodnocen( mise>: '+st+'+',false);
               str(penez,st);
               print_fc(40,91,255,'Zbyl) pen(ze: '+st+' K$',false);
               b:=((hodnoceni-500)*4)+1000+((uroven+1)*200);
               str(b,st);
               print_fc(40,101,255,'Pen(ze za misi: '+st+' K$',false);
               penez:=penez+b;
               str(penez,st);
               print_fc(40,121,1,'Celkem pen@z: '+st+' K$',false);
               print_fc(40,161,255,'Stiskni libovolnou kl*vesu.',false);
               getpal(plt);
               setblack;
               flip;
               use(vga);
               fadein(4,plt);
               readkey;
               if uroven>=maxuroven then begin
               assign(f3,'save\'+jmeno+'.sv');
               rewrite(f3);
               a:=uroven+1;
               if a>8 then a:=8;
               write(f3,a);
               write(f3,penez);
               close(f3);
               end;
               vsehotovo:=false;
               if a=9 then begin
                  a:=8;
                  outro;
                  use(virt);
                  cls(0);
                  use(vga);
                  cls(0);
                  setpal(zaklpal);
                  brief;
                  readkey;
                  vsehotovo:=true;
                  end;
               zkazeno:=true;


end;
end;

procedure tah_alienu;
var x22,y22,hejx,hejy,vzdalenost:integer;
    yyyy,body,sbody:byte;
    xxx1,xxx2,yyy1,yyy2:byte;
begin
{              schovej_mysku;}
              hranice_mysky(0,140,639,199);
              delay(200);
              body:=100;
              c:=0;
              if (typ=2) or (typ=3) then begin
                 boolprac:=false;
                 for a:=1 to pocetaln do begin
                     if energie[2,a]>0 then boolprac:=true;
                     end;
                 if (boolprac=false) and (typ=2) then spln_misi;
                 end;
              if (typ=1) or ((typ=3) and (boolprac=false)) then begin
                 for a:=0 to 100 do for b:=0 to 70 do begin
                     if mapa[a,b]=53 then begin
                        c:=c+1;
                        if c=1 then begin
                           xxx1:=a;
                           yyy1:=b;
                           end;
                        if c=4 then begin
                           xxx2:=a;
                           yyy2:=b;
                           end;
                        end;
                     end;
                 boolprac:=false;
                 for a:=1 to pocetpnk do begin
                     if ((xpostava[1,a]<xxx1) or (ypostava[1,a]<yyy1)
                        or (xpostava[1,a]>xxx2) or (ypostava[1,a]>yyy2)) and (energie[1,a]>0)
                        then boolprac:=true;
                     end;
                 if boolprac=false then spln_misi;
                 end;
{              boolprac:=false;
              for a:=1 to pocetaln do begin
                  if
                  end;

}

{          for a:=1 to pocetpnk do tahu[1,a]:=20;}
              if (zkazeno=false) {and (a=1)} then begin
              for e:=1 to pocetaln do tahu[2,e]:=15;
              for e:=1 to pocetaln do if energie[2,e]>0 then begin
                  x22:=0;
                  y22:=0;
                  hejx:=50;
                  hejy:=50;
                  sbody:=50;
                  body:=50;
{                  zmenaliena(e);
                  readkey;}
                  for c:=1 to pocetpnk do begin
                      if ((abs(xpostava[2,e]-xpostava[1,c])<15) and (abs(ypostava[2,e]-ypostava[1,c])<15))
                         and (energie[1,c]>0) then begin
                           {if hejx+hejy>(abs(xpostava[2,e]-xpostava[1,c]))+(abs(ypostava[2,e]-ypostava[1,c])) then begin}
                             body:=abs(xpostava[2,e]-xpostava[1,c])+abs(ypostava[2,e]-ypostava[1,c])+(energie[1,c] div 10);
                             if body<sbody then begin
                             sbody:=body;
                             x22:=xpostava[1,c];
                             y22:=ypostava[1,c];
                             hejx:=abs(xpostava[2,e]-xpostava[1,c]);
                             hejy:=abs(ypostava[2,e]-ypostava[1,c]);
                             end;
                           end;
                         end;
                  if (x22<>0) and (y22<>0) and
                     (((typaln[e]<>3) and (typaln[e]<>9)) or (kontrola(xpostava[2,e],ypostava[2,e],x22,y22))) then begin
                     aktivnialn:=e;
                     vzdalenost:=dosah[zbran[2,aktivnialn]];
                     for a:=1 to 30 do cesta[a]:=0;
                     if (((abs(x22-xpostava[2,aktivnialn])>dosah[zbran[2,aktivnialn]]) or (abs(y22-ypostava[2,aktivnialn])>
                        dosah[zbran[2,aktivnialn]]))
                        or (kontrola(xpostava[2,aktivnialn],ypostava[2,aktivnialn],x22,y22)=false))
                        and (typaln[aktivnialn]<>3) and (typaln[aktivnialn]<>9)  then begin
                     nejdeto:=false;
                     delay(100);
                     g:=24;
                     yyyy:=vzdalenost;
                     while {(g>20) and} (vzdalenost>0) do begin
                     nemuze3:=nemuze;
                     for a:=-(vzdalenost) to vzdalenost do begin
                         x2:=x22-(vzdalenost);
                         y2:=y22+a;
                         if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                         nemuze:=nemuze3;
                         if d<g then begin
                            yyyy:=vzdalenost;
                            g:=d;
                            end;
                         x2:=x22+(vzdalenost);
                         y2:=y22+a;
                         if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                         nemuze:=nemuze3;
                         if d<g then begin
                            yyyy:=vzdalenost;
                            g:=d;
                            end;
                         x2:=x22+a;
                         y2:=y22-(vzdalenost);
                         if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                         nemuze:=nemuze3;
                         if d<g then begin
                            yyyy:=vzdalenost;
                            g:=d;
                            end;
                         x2:=x22+a;
                         y2:=y22+(vzdalenost);
                         if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                         nemuze:=nemuze3;
                         if d<g then begin
                            yyyy:=vzdalenost;
                            g:=d;
                            end;
                         end;
                     {if g>20 then }vzdalenost:=vzdalenost-1;
                     end;
                     vzdalenost:=yyyy;
                     hmm:=false;
                     if g<=20 then begin
                     for a:=-(vzdalenost) to vzdalenost do begin
                         x2:=x22-(vzdalenost);
                         y2:=y22+a;
                         if hmm=false then begin
                            if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                            nemuze:=nemuze3;
                            if d=g then begin
                               hmm:=true;
                               end;
                            end;
                         x2:=x22+(vzdalenost);
                         y2:=y22+a;
                         if hmm=false then begin
                            if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                            nemuze:=nemuze3;
                            if d=g then begin
                               hmm:=true;
                               end;
                            end;
                         x2:=x22+a;
                         y2:=y22-(vzdalenost);
                         if hmm=false then begin
                            if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                            nemuze:=nemuze3;
                            if d=g then begin
                               hmm:=true;
                               end;
                            end;
                         x2:=x22+a;
                         y2:=y22+(vzdalenost);
                         if hmm=false then begin
                            if kontrola(x2,y2,x22,y22)=true then d:=vyzkousej(xpostava[2,e],ypostava[2,e],0) else d:=50;
                            nemuze:=nemuze3;
                            if d=g then begin
                               hmm:=true;
                               end;
                            end;
                         end;
                     nemuze:=nemuze3;
                      c:=0;
                      {while ((abs(xpostava[2,e]-x2)>3) or (abs(ypostava[2,e]-y2)>3)) and (tahu[2,e]>0) do begin}
                     if (tahu[2,aktivnialn]-g>=akcnich_bodu[zbran[2,aktivnialn]]) then begin
                     nemuze[xpostava[2,aktivnialn],ypostava[2,aktivnialn]+1]:=false;
                     zbrane(2);
                     tahy(2,aktivnialn);
                     zmenaliena(e);
                     get(nanic,(xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10-10,
                      (xpostava[2,aktivnialn]-xokolik)*10+10,(ypostava[2,aktivnialn]-yokolik)*10);
                     for a:=1 to 3 do begin
                         putrle(sprsipka,(xpostava[2,aktivnialn]-xokolik)*10+1,(ypostava[2,aktivnialn]-yokolik)*10-10);
                         delay(90);
                         put(nanic,(xpostava[2,aktivnialn]-xokolik)*10,(ypostava[2,aktivnialn]-yokolik)*10-10);
                         delay(90);
                         end;
                      for c:=0 to g-1 do begin
{                          c:=c+1;}
                          if tahu[2,e]>0 then jdi(cesta[c],e,2);
                          end;
                          nemuze[xpostava[2,aktivnialn],ypostava[2,aktivnialn]+1]:=true;
                          end;
                          end;
                          schovej_mysku;
                          setclip(0,0,309,139);
                          put_c(prac[3,e],(xpostava[2,e]-xokolik)*10-20,(ypostava[2,e]-yokolik)*10-pr2okolik);
                          putrle_c(tvor[2,9],(xpostava[2,e]-xokolik)*10,(ypostava[2,e]-yokolik)*10);
                          setclip(0,0,319,199);
                          end;
                          if (tahu[2,aktivnialn]>=akcnich_bodu[zbran[2,aktivnialn]]) then begin
                             repeat
                             x22:=0;
                             y22:=0;
                             hejx:=50;
                             hejy:=50;
                             body:=100;
                             for c:=1 to pocetpnk do begin
                                 if ((abs(xpostava[2,e]-xpostava[1,c])<=dosah[zbran[2,aktivnialn]])
                                    and (abs(ypostava[2,e]-ypostava[1,c])<=dosah[zbran[2,aktivnialn]]))
                                    and (energie[1,c]>0) and (kontrola(xpostava[2,aktivnialn],
                                    ypostava[2,aktivnialn],xpostava[1,c],ypostava[1,c])=true)
                                    then begin
{                                      if (hejx+hejy>(abs(xpostava[2,aktivnialn]-xpostava[1,c]))+(abs(ypostava[2,e]
                                         -ypostava[1,c]))) and (kontrola(xpostava[2,aktivnialn],ypostava[2,aktivnialn],
                                         xpostava[1,c],ypostava[1,c]))
                                      then begin                      }
                                        sbody:=body;
                                body:=abs(xpostava[2,e]-xpostava[1,c])+abs(ypostava[2,e]-ypostava[1,c])+(energie[1,c] div 10);
                                        if body<sbody then begin
                                        x22:=xpostava[1,c];
                                        y22:=ypostava[1,c];
                                        hejx:=abs(xpostava[2,aktivnialn]-xpostava[1,c]);
                                        hejy:=abs(ypostava[2,aktivnialn]-ypostava[1,c]);
                                        end;
                                      end;
                                    end;
                             x2:=x22;
                             y2:=y22;
                             if (x2<>0) or (y2<>0) then begin
                             souradnice((xpostava[2,aktivnialn]+x22) div 2,(ypostava[2,aktivnialn]+y22) div 2,false);
                               strela(2,e);
                               end;
                               until (tahu[2,aktivnialn]<akcnich_bodu[zbran[2,aktivnialn]]) or ((x2=0) and (y2=0));
                          end;
                          nastav_mysku(160,100);
{                          get(sipka,(mx div 20)*10,(my div 10)*10,(mx div 20)*10+10,(my div 10)*10+10);
                          square((mx div 20)*10,(my div 10)*10,(mx div 20)*10+10,(my div 10)*10+10,ba[7]);}
                          ukaz_mysku;
{                     zmenaliena(e);}
                     delay(200);
                     end;
              end;
          for a:=1 to pocetpnk do tahu[1,a]:=20;
          aktivnipnk:=1;
          while (energie[1,aktivnipnk]=0) and (aktivnipnk<20) do aktivnipnk:=aktivnipnk+1;
          if aktivnipnk>=20 then begin
               zkaz_misi;
          end;
          for a:=1 to pocetpnk do if (energie[1,a]<=0) and (muzesezabit[a]=0) and (zkazeno=false) then begin
               zkaz_misi;
               a:=pocetpnk;
               end;
          c:=0;
          for a:=1 to pocetpnk do if (energie[1,a]<=0) and (muzesezabit[a]=0) then c:=c+1;
          if c>maxztrat then zkaz_misi;
          end;
          if zkazeno=false then begin
          hodnoceni:=hodnoceni-10;
          kolo:=kolo+1;
          tahy(1,aktivnipnk);
          zmenpanaka;
          end;
          hranice_mysky(0,0,639,199);
end;

{ a:=9;
         vyzkousej(xproc+1,yproc-1);
 a:=7;
         vyzkousej(xproc-1,yproc-1);
 a:=3;
         vyzkousej(xproc+1,yproc+1);
 a:=1;
         vyzkousej(xproc-1,yproc+1);
}


(*   while ((x2<>xpostava[1,aktivnipnk]) or (y2<>ypostava[1,aktivnipnk])) and (nejdeto=false) do begin
   a:=0;
   if y2>ypostava[1,aktivnipnk] then a:=2;
   if y2<ypostava[1,aktivnipnk] then a:=8;
   if (x2>xpostava[1,aktivnipnk]) and ((a=0) or (abs(x2-xpostava[1,aktivnipnk])
      >abs(y2-ypostava[1,aktivnipnk]))) then a:=6;
   if (x2<xpostava[1,aktivnipnk]) and ((a=0) or (abs(x2-xpostava[1,aktivnipnk])
      >abs(y2-ypostava[1,aktivnipnk]))) then a:=4;

   boolprac:=false;
   if (a=8) then boolprac:=kontrola8(1,aktivnipnk);
   if (a=2) then boolprac:=kontrola2(1,aktivnipnk);
   if (a=6) then boolprac:=kontrola6(1,aktivnipnk);
   if (a=4) then boolprac:=kontrola4(1,aktivnipnk);

   if (abs(x2-xpostava[1,aktivnipnk])=abs(y2-ypostava[1,aktivnipnk])) then begin
      b:=0;
      if ((x2>=xpostava[1,aktivnipnk]) and (y2<=ypostava[1,aktivnipnk])) and (kontrola9(1,aktivnipnk)=false)
         then a:=9;
      if ((x2>=xpostava[1,aktivnipnk]) and (y2>=ypostava[1,aktivnipnk])) and (kontrola3(1,aktivnipnk)=false)
         then a:=3;
      if ((x2<=xpostava[1,aktivnipnk]) and (y2<=ypostava[1,aktivnipnk])) and (kontrola7(1,aktivnipnk)=false)
         then a:=7;
      if ((x2<=xpostava[1,aktivnipnk]) and (y2>=ypostava[1,aktivnipnk])) and (kontrola1(1,aktivnipnk)=false)
         then a:=1;

      end;

   if (boolprac=true) then begin
      b:=0;
      if ((x2>=xpostava[1,aktivnipnk]) or (y2<=ypostava[1,aktivnipnk])) and (kontrola9(1,aktivnipnk)=false)
         then begin
              a:=9;
              b:=1;
              end;
      if ((x2>=xpostava[1,aktivnipnk]) or (y2>=ypostava[1,aktivnipnk])) and (kontrola3(1,aktivnipnk)=false)
         and (b=0) then begin
              a:=3;
              b:=1;
              end;
      if ((x2<=xpostava[1,aktivnipnk]) or (y2<=ypostava[1,aktivnipnk])) and (kontrola7(1,aktivnipnk)=false)
         and (b=0) then begin
              a:=7;
              b:=1;
              end;
      if ((x2<=xpostava[1,aktivnipnk]) or (y2>=ypostava[1,aktivnipnk])) and (kontrola1(1,aktivnipnk)=false)
         and (b=0) then begin
              a:=1;
              b:=1;
              end;

      end;
   nejdeto:=false;
   if (a=8) then nejdeto:=kontrola8(1,aktivnipnk);
   if (a=2) then nejdeto:=kontrola2(1,aktivnipnk);
   if (a=6) then nejdeto:=kontrola6(1,aktivnipnk);
   if (a=4) then nejdeto:=kontrola4(1,aktivnipnk);

   if (a=7) then nejdeto:=kontrola7(1,aktivnipnk);
   if (a=9) then nejdeto:=kontrola9(1,aktivnipnk);
   if (a=3) then nejdeto:=kontrola3(1,aktivnipnk);
   if (a=1) then nejdeto:=kontrola1(1,aktivnipnk);

   if tahu[1,aktivnipnk]=0 then nejdeto:=true;    *)


procedure cekej(delka:integer);
var a:integer;
begin
while keypressed do readkey;
a:=0;
repeat
a:=a+10;
delay(10);
until (a>=delka) or (keypressed);
if keypressed then hmm:=true else hmm:=false;
while keypressed do readkey;
end;

procedure cekej2(delka:integer);
var a:integer;
begin
while keypressed do readkey;
a:=0;
repeat
a:=a+10;
delay(10);
until (a>=delka) or (keypressed);
if keypressed then hmm:=true else hmm:=false;
end;

procedure intro;
var konec:boolean;
label koncit;
begin
loadpcx(0,0,'images\planety.obr');
delay(300);
print_fc(130,170,253,'Je rok 2007.',true);
cekej(6000);
if hmm then goto koncit;
box(0,170,319,180,0);
print_fc(9,170,253,'Uf(k"m z planety Albi ze vzd*len) galaxie do#ly suroviny,',true);
cekej(6000);
if hmm then goto koncit;
box(0,170,319,180,0);
print_fc(5,170,253,'proto se rozhodli obsadit, vyvra^dit a obydlit planetu Zemi.',true);
cekej(6000);
if hmm then goto koncit;
use (virt);
cls(1);
nakreslito;
line(-1,46,321,200-45,0,true);
line(320,47,0,200-45,0,true);
box(158,99,162,101,0);
setcolor (1,24,0,0);
setcolor (2,32,0,0);
setcolor (100,24,0,0);
setcolor (101,24,0,0);
setcolor (102,24,0,0);
setcolor (103,24,0,0);
setcolor (104,24,0,0);
setcolor (105,24,0,0);
setcolor (200,34,0,0);
setcolor (201,34,0,0);
setcolor (202,34,0,0);
setcolor (203,34,0,0);
setcolor (204,34,0,0);
setcolor (205,34,0,0);
flip;
use(vga);
e:=0;
repeat
e:=e+1;
for a:=0 to 5 do begin
    setcolor (100+a,34,0,0);
    setcolor (200+a,0,0,0);
    delay(25);
    b:=a-1;
    if b=-1 then b:=5;
    setcolor (100+b,24,0,0);
    setcolor (200+b,34,0,0);
    end;
if (e=10) then begin
   box(0,170,319,180,0);
   print_fc(58,170,253,'D(ky mezigalaktick)mu tunelu se na Zemi',true);
   e:=11;
   end;
if (e=40) then begin
   box(0,170,319,180,0);
   print_fc(95,170,253,'dostali prakticky okam^it@.',true);
   e:=41;
   end;
if c=0 then c:=1;
until (e=80) or (keypressed);
if keypressed then goto koncit;
loadpcx(0,0,'images\planety2.obr');
delay(500);
print_fc(35,170,253,'Zem@ se pr*v@ dozv@d@la o hroz(c(m nebezpe$(.',true);
cekej(6000);
if hmm then goto koncit;
box(0,170,319,180,0);
print_fc(40,170,253,'V rychlosti byly rozestav@ny vojensk) s(ly.',true);
cekej(6000);
if hmm then goto koncit;
box(0,170,319,180,0);
print_fc(100,170,253,'A co je tv&m "kolem ?',true);
cekej(6000);
if hmm then goto koncit;
box(0,170,319,180,0);
print_fc(130,170,253,'No co asi.',true);
cekej(6000);
koncit:
getpal(plt);
fadeout(4,plt);
setblack;
end;

procedure brifing;
var st:string;
begin
use(vga);
setpal(plt);
fadeout(6,plt);
setblack;
xokolik:=0;
yokolik:=0;
zobraz;
rezim:=1;
box(0,140,319,150,ba[7]);
square(310,0,319,150,ba[7]);
box(311,1,319,139,ba[7]);
square(0,140,319,150,ba[7]);
box(1,141,9,149,ba[13]);
box(311,1,319,9,ba[13]);
box(311,131,319,139,ba[13]);
box(300,141,309,149,ba[13]);

putpixel(3,145,0);
line(4,144,4,146,0,false);
line(5,143,5,147,0,false);

putpixel(305,145,0);
line(304,144,304,146,0,false);
line(303,143,303,147,0,false);

putpixel(315,136,0);
line(314,135,316,135,0,false);
line(313,134,317,134,0,false);

putpixel(315,4,0);
line(314,5,316,5,0,false);
line(313,6,317,6,0,false);

box(0,150,319,199,0);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*22);
square(5,160,315,190,ba[7]);
box(6,161,314,189,0);
fadein(4,plt2);
str(uroven,st);
assign(tx,'levels\level0'+st+'.brf');
reset(tx);
while keypressed do readkey;
repeat
readln(tx,st);
readln(tx,st2);
if st='cekej' then begin
        val(st2,a,b);
        cekej2(a);
        end;
if st='souradnice' then begin
        readln(tx,st);
        val(st2,a,b);
        val(st,b,c);
        souradnice(a,b,true);
        end;
if st='panak' then begin
        val(st2,a,b);
        b:=xpostava[1,a];
        c:=ypostava[1,a];
        souradnice(b,c,true);
        end;
if st='napis' then begin
        box(6,161,314,189,0);
         use(virt);
         cls(0);
         print_fc(0,0,ba[14],st2,false);
         b:=0;
         c:=319;
         while (b=0) and (c>0) do begin
            c:=c-1;
            for d:=0 to 14 do begin
                if getpixel(c,d)<>0 then b:=1;
                end;
            end;
         get(titulky[1],0,0,c,14);
         use(vga);
         put(titulky[1],160-(c div 2),170);
        end;
until (eof(tx)) or keypressed;
while keypressed do readkey;
if eof(tx) then readkey;
close(tx);
getpal(plt);
end;

procedure zobraz_levely(vyb:byte);
begin
schovej_mysku;
box(35,40,175,140,0);
box(35,40+(vyb*10),175,49+(vyb*10),13);
if maxuroven>=1 then print_fc(40,40+(1-1)*10,14,'Prvn( st%et',false)
   else print_fc(40,40+(1-1)*10,88,'Prvn( st%et',false);
if maxuroven>=2 then print_fc(40,40+(2-1)*10,14,'"t@k z pou#t@',false)
   else print_fc(40,40+(2-1)*10,88,'"t@k z pou#t@',false);
if maxuroven>=3 then print_fc(40,40+(3-1)*10,14,'Boj o ostrov',false)
   else print_fc(40,40+(3-1)*10,88,'Boj o ostrov',false);
if maxuroven>=4 then print_fc(40,40+(4-1)*10,14,'Ne$ekan& "tok',false)
   else print_fc(40,40+(4-1)*10,88,'Ne$ekan& "tok',false);
if maxuroven>=5 then print_fc(40,40+(5-1)*10,14,'15 ostrov"',false)
   else print_fc(40,40+(5-1)*10,88,'15 ostrov"',false);
if maxuroven>=6 then print_fc(40,40+(6-1)*10,14,'"t@k zajatc"',false)
   else print_fc(40,40+(6-1)*10,88,'"t@k zajatc"',false);
if maxuroven>=7 then print_fc(40,40+(7-1)*10,14,'P%epaden( na pou#ti',false)
   else print_fc(40,40+(7-1)*10,88,'P%epaden( na pou#ti',false);
if maxuroven>=8 then print_fc(40,40+(8-1)*10,14,'Atent*t na v"dce',false)
   else print_fc(40,40+(8-1)*10,88,'Atent*t na v"dce',false);
{for a:=1 to 2 do begin
    str(a,st);
    print_fc(40,40+(a-1)*10,14,'Level '+st,false);
    end;}
ukaz_mysku;
end;

procedure ukaz_mapu(lvv:byte);
var st:string;
begin
use(virt);
cls(0);
loadpcx(0,0,'images\nahrav.obr');
get(nanic,0,0,99,69);
use(vga);
put(nanic,186,32);
loadfont('fonts\pav2.fn');
st:='';
str(lvv,st);
assign(tx,'levels\level0'+st+'.inf');
reset(tx);
readln(tx,st);
a:=0;
box(189,105,285,150,0);
print_fc(188,110,15,'cil mise:',false);
{repeat
a:=a+1;}
readln(tx,st);
print_fc(188,110+9,14,st,false);
print_fc(188,110+18,15,'povolene ztraty:',false);
readln(tx,st);
print_fc(188,110+27,14,st,false);

{until eof(tx);}
close(tx);
loadfont('fonts\pavel.fn');
setclip(186,32,285,101);
nacti(lvv);
schovej_mysku;
for a:=0 to 100 do for b:=0 to 70 do begin
    case mapa[a,b] of
       0,3,5,6,7,12,13,14,15,17,18,19,20,29,30,31,32,38,40,41,43,44,53:putpixel_c(a+186,b+32,86);
       1,21,22,23,24,34,35,36,37:putpixel_c(a+186,b+32,87);
       45,46,47,48,49,50,51,52:putpixel_c(a+186,b+32,88);
       2,4,25,26,27,28,33:putpixel_c(a+186,b+32,89);
       39,42:putpixel_c(a+186,b+32,0);
       8,9,10,11,16:putpixel_c(a+186,b+32,90);
       end;
    end;
for a:=0 to 100 do for b:=0 to 70 do begin
    case spesl[a,b] of
       1:begin
         putpixel_c(a+186,b+32,91);
         putpixel_c(a+186+1,b+32+1,91);
         putpixel_c(a+186,b+32+1,91);
         putpixel_c(a+186+1,b+32,91);
         end;
       2:begin
         putpixel_c(a+186,b+32,91);
         putpixel_c(a+186+1,b+32+1,91);
         putpixel_c(a+186,b+32+1,91);
         putpixel_c(a+186+1,b+32,91);
         putpixel_c(a+186,b+32+2,91);
         putpixel_c(a+186+1,b+32+2,91);
         end;
       3:begin
         putpixel_c(a+186,b+32,91);
         putpixel_c(a+186,b+32+1,91);
         putpixel_c(a+186,b+32+2,91);
         putpixel_c(a+186,b+32+3,91);
         end;
       4:begin
         putpixel_c(a+186+1,b+32,91);
         putpixel_c(a+186,b+32+1,91);
         putpixel_c(a+186+1,b+32+1,91);
         putpixel_c(a+186+2,b+32+1,91);
         end;
       5:begin
         putpixel_c(a+186+1,b+32,92);
         putpixel_c(a+186+2,b+32,92);
         putpixel_c(a+186,b+32+1,92);
         putpixel_c(a+186+1,b+32+1,92);
         putpixel_c(a+186+2,b+32+1,92);
         putpixel_c(a+186+3,b+32+1,92);

         putpixel_c(a+186,b+32+2,89);
         putpixel_c(a+186+1,b+32+2,89);
         putpixel_c(a+186+2,b+32+2,89);
         putpixel_c(a+186+3,b+32+2,89);
         putpixel_c(a+186,b+32+3,89);
         putpixel_c(a+186+1,b+32+3,89);
         putpixel_c(a+186+2,b+32+3,89);
         putpixel_c(a+186+3,b+32+3,89);
         end;
       6:begin
         putpixel_c(a+186,b+32,91);
         putpixel_c(a+186,b+32+1,91);
         putpixel_c(a+186,b+32+2,91);
         end;
       7:begin
         putpixel_c(a+186,b+32,89);
         putpixel_c(a+186,b+32+1,89);
         putpixel_c(a+186,b+32+2,89);
         end;
       8:begin
         putpixel_c(a+186,b+32,88);
         end;
       9:begin
         putpixel_c(a+186,b+32,88);
         putpixel_c(a+186+1,b+32,88);
         putpixel_c(a+186,b+32+1,88);
         putpixel_c(a+186+1,b+32+1,88);
         end;
       10,11,12:begin
         putpixel_c(a+186,b+32,89);
         putpixel_c(a+186+1,b+32,89);
         end;
       end;
    end;
for a:=1 to pocetpnk do begin
    putpixel_c(xpostava[1,a]+186-1,ypostava[1,a]+32,15);
    putpixel_c(xpostava[1,a]+186+1,ypostava[1,a]+32,15);
    putpixel_c(xpostava[1,a]+186,ypostava[1,a]+32+1,15);
    putpixel_c(xpostava[1,a]+186,ypostava[1,a]+32-1,15);
    end;
for a:=1 to pocetaln do begin
    putpixel_c(xpostava[2,a]+186-1,ypostava[2,a]+32,92);
    putpixel_c(xpostava[2,a]+186+1,ypostava[2,a]+32,92);
    putpixel_c(xpostava[2,a]+186,ypostava[2,a]+32-1,92);
    putpixel_c(xpostava[2,a]+186,ypostava[2,a]+32+1,92);
    end;
setclip(0,0,319,199);
ukaz_mysku;
nastav_sipku;
end;

procedure level;
begin
use(virt);
loadpcx(0,0,'images\level2.obr');
get(stlacena[1],0,0,70,20);
get(stlacena[2],70,0,139,20);
loadpcx(0,0,'images\level.obr');
get(tlacitka[1],90,170,160,191);
get(tlacitka[2],160,170,230,191);
getpal(plt);
setblack;
flip;
use(vga);
fadein(4,plt);
{$I-}
assign(f3,'save\'+jmeno+'.sv');
reset(f3);
{$I+}
if IOresult=0 then begin
{   b:=uroven;}
   read(f3,b);
   uroven:=b;
   maxuroven:=b;
   read(f3,penez);
   end else begin
       uroven:=1;
       maxuroven:=1;
       penez:=2000;
       end;
{37,35,175,148}
g:=uroven-1;
zobraz_levely(g);
ukaz_mapu(g+1);
ukaz_mysku;
muzes:=false;
repeat
smx:=mx;
smy:=my;
smb1:=mb1;
smb2:=mb2;
pozice_mysky (mx,my,mb1,mb2,mbnanic);
mxx:=mx div 2;
smxx:=smx div 2;
if (lezivhranici(40,40,145,115)) and (mb1=true) then begin
   h:=g;
   g:=(my-40) div 10;
   if g>maxuroven-1 then g:=maxuroven-1;
   if (g<>h) or (smb1=false) then zobraz_levely(g);
   ukaz_mapu(g+1);
   uroven:=g+1;
   end;
for a:=1 to 2 do begin
    if (lezivhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190)
       and (lezelvhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190)=false)) then begin
       schovej_mysku;
       put(stlacena[a],90+(a-1)*70,170);
       ukaz_mysku;
       end;
    if (lezivhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190)) and (mb1) and (smb1=false) then begin
       schovej_mysku;
       put(stlacena[a],90+(a-1)*70+1,171);
       square(90+(a-1)*70,170,160+(a-1)*70,190,254);
       ukaz_mysku;
       end;
    if (lezivhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       put(tlacitka[a],90+(a-1)*70,170);
       muzes:=true;
       if a=2 then uroven:=0;
       ukaz_mysku;
       end;
    if (lezelvhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190))
       and (lezivhranici(90+(a-1)*70+(a-1),170,160+(a-1)*70+(a-1),190)=false) then begin
       schovej_mysku;
       put(tlacitka[a],90+(a-1)*70,170);
       ukaz_mysku;
       end;
    end;
until muzes;
schovej_mysku;

end;



procedure kredity;
begin
          schovej_mysku;
         get(bnanic,0,0,319,199);
         getpal(plt);
         cls(0);
         use(virt);
         setpal(zaklpal);
         cls(0);
         use(vga);
         c:=0;
         brief;
         use(vga);
(*         print_fc(0,0,15,st,false);
         b:=0;
         c:=319;
         while (b=0) and (c>0) do begin
            c:=c-1;
            for d:=0 to 14 do begin
                if getpixel(c,d)<>0 then b:=1;
                end;
            end;
         cls(0);
{         print_fc((312-c) div 2,0,15,kredity[a],false);}
         zacatek[a]:=(312-c) div 2;
         print_fc(0,0,15,st,false);
         get(titulky[a],0,0,c,14);
         cls(0);
         end;
         use(vga);
         for b:=1 to 71*14 do begin
{             cls(0);}
             for a:=1 to 100 do if (a*15-b+200>-15) and (a*15-b+200<210) then put_c(titulky[a],zacatek[a],a*15-b+200);
             delay(100);
             if b=150 then delay(1000);
             if keypressed then b:=71*14;
         end;
         readkey;
         cls(0);
         setpal(plt);
         put(bnanic,0,0);
         nastav_mysku(mx,my);
         killsprite(bnanic);
         for a:=1 to 65 do killsprite(titulky[a]);
         mb1:=false;
         smb1:=false;
         ukaz_mysku;
         a:=2;
         b:=0;
         c:=4;*)
         readkey;
         cls(0);
         setpal(plt);
         put(bnanic,0,0);
         nastav_mysku(mx,my);
         mb1:=false;
         smb1:=false;
         ukaz_mysku;
         a:=2;
         b:=0;
         c:=4;
         end;

procedure nacti_inventar;
var st:string;
    bt:byte;
begin
str(uroven,st);
assign(f2,'levels\level0'+st+'.inv');
reset(f2);
read(f2,typ);
read(f2,maxztrat);
 for a:=1 to pocetpnk do begin
     read(f2,muzesezabit[a]);
     for b:=1 to 11 do begin
         read(f2,bt);
{     veci:array[0..17] of string[25] = ('neozbrojen','pistolka','ostrel,','samopal','plamenomet','granat',
                                       'raketomet','mina','nuz','tyc','kamen','lekarna','10 naboju: pistolka',
                                       '5 naboju: ostrelovacka','10 naboju: samopal','10x plyn do plamenometu',
                                       '1 raketa','dynamit');}
         if ((b=1) or (b=3) or (b=4)) and (bt=1) then bt:=10;
         if (b=2) and (bt=2) then bt:=5;
         pk[a,b]:=bt;
         if pk[a,b]=0 then pk[a,b]:=-1;
         end;
     read(f2,bt);
     pk[a,17]:=bt;
     if pk[a,17]=0 then pk[a,17]:=-1;
     end;
 close(f2);
 for a:=1 to pocetpnk do begin
     zbran[1,a]:=0;
     repeat zbran[1,a]:=zbran[1,a]+1 until (pk[a,zbran[1,a]]>0) or (zbran[1,a]>=20);
     if zbran[1,a]>=20 then zbran[1,a]:=0;
     end;
end;

procedure napis_zbrane(akt:integer);
var st:string;
    a,b:integer;
    aktivni:boolean;
begin
 box(18,33,201,163,0);
 box(18,34+(akt-1)*8,201,41+(akt-1)*8,16);
 box(17,172,203,186,0);
 box(18,34+(akt-1)*8,201,41+(akt-1)*8,16);
 for a:=1 to 16 do begin
     aktivni:=true;
     if (a=1) or (a=2) or (a=3) or (a=4) or (a=6) or (a=7) or (a=8) or (a=9) then begin
        if pk[aktivnipnk,a]>-1 then aktivni:=false;
        end;
     if (a=12) and (pk[aktivnipnk,1]<0) then aktivni:=false;
     if (a=13) and (pk[aktivnipnk,2]<0) then aktivni:=false;
     if (a=14) and (pk[aktivnipnk,3]<0) then aktivni:=false;
     if (a=15) and (pk[aktivnipnk,4]<0) then aktivni:=false;
     if (a=16) and (pk[aktivnipnk,6]<0) then aktivni:=false;
     if cena[a]>penez then aktivni:=false;
     if aktivni then begin
        if a=akt then print_fc(27,35+(a-1)*8,14,veci[a],false) else print_fc(27,35+(a-1)*8,15,veci[a],false);
        str(cena[a],st);
        if a=akt then print_fc(170,35+(a-1)*8,14,st+',-',false) else print_fc(170,35+(a-1)*8,15,st+',-',false);
     end else begin
         print_fc(27,35+(a-1)*8,195,veci[a],false);
         str(cena[a],st);
         print_fc(170,35+(a-1)*8,195,st+',-',false);
         end;
     end;
 b:=0;
 box(217,35,300,135,0);
 for a:=1 to 11 do begin
     if pk[aktivnipnk,a]>-1 then begin
        print_fc(220,35+b*8,15,veci[a],false);
        str(pk[aktivnipnk,a],st);
        print_fc(280,35+b*8,15,st+' ks',false);
        b:=b+1;
        end;
     end;
 loadfont('fonts\pavel.fn');
 str(penez,st);
 print_fc(25,175,14,'Zb&v* ti: '+st+' K$',false);
 loadfont('fonts\pav2.fn');
end;

procedure hra;
begin
cls(0);
use(virt);
loadpcx(0,0,'images\loading.obr');
getpal(plt);
{setblack;}
flip;
cls(0);
kolo:=1;
aktivnipnk:=1;
aktivnialn:=1;
zkazeno:=false;
hodnoceni:=500;
nacti(uroven);
{zobraz;
setpal(plt2);
flip;
readkey;}
nacti_inventar;
for a:=1 to pocetpnk do energie[1,a]:=50;
for a:=1 to pocetpnk do cenergie[1,a]:=50;
for a:=1 to pocetaln do energie[2,a]:=30;
for a:=1 to 50 do cenergie[2,a]:=30;

for a:=1 to pocetpnk do tahu[1,a]:=20;
for a:=1 to pocetaln do tahu[2,a]:=15;
{getpal(plt2);
{fadeout(2,plt2);

{fadein(40,plt2);}


brifing;


zobraz;
use(virt);
rezim:=1;
box(0,140,319,150,ba[7]);
square(310,0,319,150,ba[7]);
box(311,1,319,139,ba[7]);
square(0,140,319,150,ba[7]);
box(1,141,9,149,ba[13]);
box(311,1,319,9,ba[13]);
box(311,131,319,139,ba[13]);
box(300,141,309,149,ba[13]);

putpixel(3,145,0);
line(4,144,4,146,0,false);
line(5,143,5,147,0,false);

putpixel(305,145,0);
line(304,144,304,146,0,false);
line(303,143,303,147,0,false);

putpixel(315,136,0);
line(314,135,316,135,0,false);
line(313,134,317,134,0,false);

putpixel(315,4,0);
line(314,5,316,5,0,false);
line(313,6,317,6,0,false);

box(0,150,319,199,0);
for a:=0 to 20 do for b:=0 to 4 do put_c(sprlogo,a*22,150+b*22);
line (1,177,318,177,ba[12],false);
line (1,195,318,195,ba[12],false);
box (1,178,318,194,ba[4]);
square(0,150,319,199,ba[7]);
line(319,151,319,199,ba[15],false);
line(319,199,1,199,ba[15],false);
for a:=0 to 1 do begin
    tlac(a*16+10,180);
    putrle(sprtlacitko[a],a*16+14,182);
    end;
for a:=2 to 4 do begin
    tlac(a*16+15,180);
    putrle(sprtlacitko[a],a*16+19,182);
    end;

    tlac(5*16+20,180);
    putrle(sprtlacitko[5],5*16+24,182);

    box(116,180,184,192,ba[8]);
    line (116,180,184,180,0,false);
    line (116,192,184,192,ba[7],false);

    tlac(184,180);
    putrle(sprtlacitko[6],188,182);

for a:=0 to 2 do begin
    tlac2(a*35+205,180);
    putrle(sprtlacitko[a+7],a*35+209,183);
    end;

print_fc(18,153,ba[15],'akce:',false);
print_fc(18,163,ba[15],'^ivot:',false);
print_fc(163,153,ba[15],'rep.:',false);
tahy(1,aktivnipnk);
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
{box(312,11+round(yokolik*(95/(29-15))),318,20+round(yokolik*(95/(29-15))),ba[3]);
box(11+round(xokolik*(263/(49-31))),142,20+round(xokolik*(263/(49-31))),148,ba[3]);}
zbrane(1);
use(vga);
setpal(plt);
fadeout(6,plt);
setblack;
use(virt);
flip;
use(vga);
fadein(6,plt2);
zmenpanaka;
nastav_mysku(160,150);
ukaz_mysku;
repeat
smx:=mx;
smy:=my;
smb1:=mb1;
smb2:=mb2;
pozice_mysky (mx,my,mb1,mb2,mbnanic);
mxx:=mx div 2;
smxx:=smx div 2;
if (lezivhranici(0,0,309,139)) and (lezelvhranici(0,0,309,139)=false) then begin
   schovej_mysku;
   end;
if (lezivhranici(0,0,309,139)=false) and (lezelvhranici(0,0,309,139)) then begin
   ukaz_mysku;
   end;
if (lezivhranici(0,0,309,139)) and (mb2) and (smb2=false) then begin
if rezim=2 then rezim:=1 else rezim:=2;
   ukaz_kurzor;
end;


if (lezivhranici(0,0,309,139)) and (lezelvhranici(0,0,309,139)=false) and ((mx<>smx) or (my<>smy)) then begin
   x1:=(mx div 20);
   y1:=(my div 10);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
   if rezim=1 then square(x1*10,y1*10,x1*10+10,y1*10+10,ba[7]) else begin
      line(x1*10+1,y1*10+1,x1*10+9,y1*10+9,ba[12],false);
      line(x1*10+9,y1*10+1,x1*10+1,y1*10+9,ba[12],false);
      end;
   end;

if (lezivhranici(0,0,309,139)) and (lezelvhranici(0,0,309,139)) and ((mx<>smx) or (my<>smy)) then begin
   x1:=(mx div 20);
   y1:=(my div 10);
   x2:=(smx div 20);
   y2:=(smy div 10);
   put_c(sipka,x2*10,y2*10);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
   if rezim=1 then square(x1*10,y1*10,x1*10+10,y1*10+10,ba[7]) else begin
      line(x1*10+1,y1*10+1,x1*10+9,y1*10+9,ba[12],false);
      line(x1*10+9,y1*10+1,x1*10+1,y1*10+9,ba[12],false);
      end;
   end;

if (lezelvhranici(0,0,309,139)) and (lezivhranici(0,0,309,139)=false) and ((mx<>smx) or (my<>smy)) then begin
   x2:=(smx div 20);
   y2:=(smy div 10);
   put_c(sipka,x2*10,y2*10);
   end;


{tlacitko (10,177,'tah');
tlacitko (63,177,'Vtok');
tlacitko (116,177,' dalSI');
tlacitko (260,157,'konec');
tlacitko (260,177,' cIl mise');}
{if lezivhranici(63,177,113,177)}

for a:=0 to 1 do begin
    if (lezivhranici(a*16+10,180,a*16+25,192)) and
       (mb1) and ((smb1=false) or (lezelvhranici(a*16+10,180,a*16+25,192)=false)) then begin
       schovej_mysku;
       stlac(a*16+10,180);
       putrle(sprtlacitko[a],a*16+15,183);
       ukaz_mysku;
       end;
    if (lezelvhranici(a*16+10,180,a*16+25,192)) and
       (mb1) and (lezivhranici(a*16+10,180,a*16+25,192)=false) then begin
       schovej_mysku;
       tlac(a*16+10,180);
       putrle(sprtlacitko[a],a*16+14,182);
       ukaz_mysku;
       end;
    if (lezelvhranici(a*16+10,180,a*16+25,192)) and (mb1=false) and (smb1) then begin
       if a=1 then begin
         zkazeno:=true;
         ch:=#27;
         end else begin
             schovej_mysku;
             tlac(a*16+10,180);
             putrle(sprtlacitko[a],a*16+14,182);
             loadpcx(35,10,'images\help.obr');
             while keypressed do readkey;
             readkey;
             zobraz;
             ukaz_mysku;
             end;
       end;
    end;
{for a:=2 to 4 do begin
    tlac(a*16+15,180);
    putrle(sprtlacitko[a],a*16+19,182);
    end;

    tlac(5*16+20,180);
    putrle(sprtlacitko[5],5*16+24,182);

    box(116,180,184,192,ba[8]);
    line (116,180,184,180,0,false);
    line (116,192,184,192,ba[7],false);

    tlac(184,180);
    putrle(sprtlacitko[6],188,182);}
for a:=2 to 4 do begin
    if (lezivhranici(a*16+15,180,a*16+30,192)) and
       (mb1) and ((smb1=false) or (lezelvhranici(a*16+15,180,a*16+30,192)=false)) then begin
       schovej_mysku;
       stlac(a*16+15,180);
       putrle(sprtlacitko[a],a*16+20,183);
       ukaz_mysku;
       end;
    if (lezelvhranici(a*16+15,180,a*16+30,192)) and
       (mb1) and (lezivhranici(a*16+15,180,a*16+30,192)=false) then begin
       schovej_mysku;
       tlac(a*16+15,180);
       putrle(sprtlacitko[a],a*16+19,182);
       ukaz_mysku;
       end;
    if (lezelvhranici(a*16+15,180,a*16+30,192)) and (mb1=false) and (smb1) then begin
       case a of
         2:begin
       schovej_mysku;
       tlac(a*16+15,180);
       putrle(sprtlacitko[a],a*16+19,182);
       ukaz_mysku;
       rezim:=1;
           end;
         3:begin
       schovej_mysku;
       tlac(a*16+15,180);
       putrle(sprtlacitko[a],a*16+19,182);
       ukaz_mysku;
           if (spesl[xpostava[1,aktivnipnk],ypostava[1,aktivnipnk]+1]>19) and (tahu[1,aktivnipnk]>3) then begin
              case spesl[xpostava[1,aktivnipnk],ypostava[1,aktivnipnk]+1] of
                   20:cenergie[1,aktivnipnk]:=cenergie[1,aktivnipnk]+10;
                   21:pk[aktivnipnk,1]:=pk[aktivnipnk,1]+10;
                   22:pk[aktivnipnk,2]:=pk[aktivnipnk,2]+5;
                   23:pk[aktivnipnk,3]:=pk[aktivnipnk,3]+10;
                   24:pk[aktivnipnk,4]:=pk[aktivnipnk,4]+10;
                   25:pk[aktivnipnk,5]:=pk[aktivnipnk,5]+5;
                   26:penez:=penez+1000;
                   27:pk[aktivnipnk,11]:=pk[aktivnipnk,11]+1;
                   28:penez:=penez+5000;
                   29:tahu[1,aktivnipnk]:=24;
                   end;
              spesl[xpostava[1,aktivnipnk],ypostava[1,aktivnipnk]+1]:=0;
              zobraz;
              tahu[1,aktivnipnk]:=tahu[1,aktivnipnk]-4;
              tahy(1,aktivnipnk);
              end else begin
                  init1('sounds\fuckyou.wav');
                  play1;
                  end;
           end;{:halt;}
         4:begin
       schovej_mysku;
       tlac(a*16+15,180);
       putrle(sprtlacitko[a],a*16+19,182);
       ukaz_mysku;
       rezim:=2;
           end;
         end;
       end;
    end;


    if (lezivhranici(5*16+20,180,5*16+35,192)) and
       (mb1) and ((smb1=false) or (lezelvhranici(5*16+20,180,5*16+35,192)=false)) then begin
       schovej_mysku;
       stlac(5*16+20,180);
       putrle(sprtlacitko[5],5*16+25,183);
       ukaz_mysku;
       end;
    if (lezelvhranici(5*16+20,180,5*16+35,192)) and
       (mb1) and (lezivhranici(5*16+20,180,5*16+35,192)=false) then begin
       schovej_mysku;
       tlac(5*16+20,180);
       putrle(sprtlacitko[5],5*16+24,182);
       ukaz_mysku;
       end;
    if (lezelvhranici(5*16+20,180,5*16+35,192)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       tlac(5*16+20,180);
       putrle(sprtlacitko[5],5*16+24,182);
       c:=zbran[1,aktivnipnk];
       repeat
          zbran[1,aktivnipnk]:=zbran[1,aktivnipnk]-1;
       until (pk[aktivnipnk,zbran[1,aktivnipnk]]>0) or (zbran[1,aktivnipnk]<1);
       if zbran[1,aktivnipnk]<1 then zbran[1,aktivnipnk]:=c else zbrane(1);
       ukaz_mysku;
       end;

    if (lezivhranici(184,180,199,192)) and
       (mb1) and ((smb1=false) or (lezelvhranici(184,180,199,192)=false)) then begin
       schovej_mysku;
       stlac(184,180);
       putrle(sprtlacitko[6],189,183);
       ukaz_mysku;
       end;
    if (lezelvhranici(184,180,199,192)) and
       (mb1) and (lezivhranici(184,180,199,192)=false) then begin
       schovej_mysku;
       tlac(184,180);
       putrle(sprtlacitko[6],188,182);
       ukaz_mysku;
       end;
    if (lezelvhranici(184,180,199,192)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       tlac(184,180);
       putrle(sprtlacitko[6],188,182);
       c:=zbran[1,aktivnipnk];
       repeat
          zbran[1,aktivnipnk]:=zbran[1,aktivnipnk]+1;
       until (pk[aktivnipnk,zbran[1,aktivnipnk]]>0) or (zbran[1,aktivnipnk]>11);
       if zbran[1,aktivnipnk]>11 then zbran[1,aktivnipnk]:=c else zbrane(1);
       ukaz_mysku;
       end;

{    tlac(5*16+20,180);
    putrle(sprtlacitko[5],5*16+24,182);

    box(116,180,184,192,ba[8]);
    line (116,180,184,180,0,false);
    line (116,192,184,192,ba[7],false);

    tlac(184,180);
    putrle(sprtlacitko[6],188,182);}
for b:=0 to 2 do begin
    if (lezivhranici(b*35+205,180,b*35+239,192)) and
       (mb1) and ((smb1=false) or (lezelvhranici(b*35+205,180,b*35+239,192)=false)) then begin
       schovej_mysku;
       stlac2(b*35+205,180);
       putrle(sprtlacitko[b+7],b*35+210,184);
       ukaz_mysku;
       end;
    if (lezelvhranici(b*35+205,180,b*35+239,192)) and
       (mb1) and (lezivhranici(b*35+205,180,b*35+239,192)=false) then begin
       schovej_mysku;
       tlac2(b*35+205,180);
       putrle(sprtlacitko[b+7],b*35+209,183);
       ukaz_mysku;
       end;
    if (lezelvhranici(b*35+205,180,b*35+239,192)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       tlac2(b*35+205,180);
       putrle(sprtlacitko[b+7],b*35+209,183);
       ukaz_mysku;
       case b of
          2:begin
              repeat
              aktivnipnk:=aktivnipnk+1;
              if aktivnipnk>pocetpnk then aktivnipnk:=1;
              until (energie[1,aktivnipnk]>0);
              zmenpanaka;
              b:=2;
              end;
          1:begin
              t:=b;
              nastav_ihodinky;
              tah_alienu;
              if zkazeno then ch:=#27;
              nastav_sipku;
              b:=t;
            end;
          0:begin
            schovej_mysku;
            get(nanic,0,0,319,199);
            fadeout(4,plt2);
            setblack;
            cls(0);
            use(virt);
            loadpcx(0,0,'images\shop2.obr');
            get(stlacena[1],0,0,89,20);
            get(stlacena[2],0,21,89,43);
            loadpcx(0,0,'images\shop.obr');
            get(tlacitka[1],214,146,304,166);
            get(tlacitka[2],214,167,304,190);
            getpal(plt);
            setblack;
            loadfont('fonts\pav2.fn');
            napis_zbrane(1);
            flip;
            use(vga);
            fadein(4,plt);
muzes:=false;
ukaz_mysku;
g:=1;
repeat
smx:=mx;
smy:=my;
smb1:=mb1;
smb2:=mb2;
pozice_mysky (mx,my,mb1,mb2,mbnanic);
mxx:=mx div 2;
smxx:=smx div 2;
{if (lezivhranici(40,40,170,140)) and (mb1=true) then begin
   h:=g;
   g:=(my-40) div 10;
   if (g<>h) or (smb1=false) then zobraz_levely(g);
   if (g=0) or (g=1) then ukaz_mapu(g+1);
   uroven:=g+1;
   end;}
{ for a:=1 to 16 do print_fc(27,35+(a-1)*9,254,veci[a],false);}
if (lezivhranici(27,35,200,40+15*8)) and (mb1=true) then begin
   h:=g;
   g:=((my-33) div 8)+1;
   if (g<>h) or (smb1=false) then begin
      schovej_mysku;
      napis_zbrane(g);
      ukaz_mysku;
      end;
   end;
{            get(tlacitka[1],214,146,304,166);}
for a:=1 to 2 do begin
    if (lezivhranici(214,146+(a-1)*21,304,166+(a-1)*21)
       and (lezelvhranici(214,146+(a-1)*21,304,166+(a-1)*21)=false)) then begin
       schovej_mysku;
       put(stlacena[a],214,146+(a-1)*21);
       ukaz_mysku;
       end;
    if (lezivhranici(214,146+(a-1)*21,304,166+(a-1)*21)) and (mb1) and (smb1=false) then begin
       schovej_mysku;
       put(stlacena[a],215,147+(a-1)*21);
       square(218,147+(a-1)*21,300,165+(a-1)*21,254);
       ukaz_mysku;
       end;
    if (lezivhranici(214,146+(a-1)*21,304,166+(a-1)*21)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       put(tlacitka[a],214,146+(a-1)*21);
       if a=1 then begin
          boolprac:=true;
          if cena[g]>penez then boolprac:=false;
          if (g=1) or (g=2) or (g=3) or (g=4) or (g=6) or (g=7) or (g=8) or (g=9) then begin
             if pk[aktivnipnk,g]>0 then boolprac:=false;
             end;
          if (g=12) and (pk[aktivnipnk,1]<0) then boolprac:=false;
          if (g=13) and (pk[aktivnipnk,2]<0) then boolprac:=false;
          if (g=14) and (pk[aktivnipnk,3]<0) then boolprac:=false;
          if (g=15) and (pk[aktivnipnk,4]<0) then boolprac:=false;
          if (g=16) and (pk[aktivnipnk,6]<0) then boolprac:=false;
          if boolprac then begin

          if (g=1) or (g=3) or (g=4) then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,g]:=pk[aktivnipnk,g]+10;
             end;
          if g=2 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,g]:=pk[aktivnipnk,g]+5;
             end;
          if (g<12) and (g>4) then begin
{      veci:array[0..17] of string[25] = ('neozbrojen','pistolka','ostrel,','samopal','plamenomet','granat',
                                       'raketomet','mina','nuz','tyc','kamen','lekarna','10 naboju: pistolka',
                                       '5 naboju: ostrelovacka','10 naboju: samopal','10x plyn do plamenometu',
                                       '1 raketa','dynamit');}
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             end;
          if g=12 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,1]:=pk[aktivnipnk,1]+10;
             end;
          if g=13 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,2]:=pk[aktivnipnk,2]+5;
             end;
          if g=14 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,3]:=pk[aktivnipnk,3]+10;
             end;
          if g=15 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,4]:=pk[aktivnipnk,4]+10;
             end;
          if g=16 then begin
             if pk[aktivnipnk,g]=-1 then pk[aktivnipnk,g]:=pk[aktivnipnk,g]+1;
             pk[aktivnipnk,6]:=pk[aktivnipnk,6]+1;
             end;
          penez:=penez-cena[g];
          napis_zbrane(g);
          end;
{veci:array[1..16] of string[25] = ('pistolka','ostrelovacka','samopal','plamenomet','granat',
 'raketomet','mina','nuz','pendrek','kamen','lekarna','10 naboju: pistolka',
 '5 naboju: ostrelovacka','10 naboju: samopal','10x plyn do plamenometu',
 '1 raketa');}

          end;
       if a=2 then muzes:=true;
       ukaz_mysku;
       end;
    if (lezelvhranici(214,146+(a-1)*21,304,166+(a-1)*21))
       and (lezivhranici(214,146+(a-1)*21,304,166+(a-1)*21)=false) then begin
       schovej_mysku;
       put(tlacitka[a],214,146+(a-1)*21);
       ukaz_mysku;
       end;
    end;
until muzes;
            loadfont('fonts\pavel.fn');

 {            loadpcx(0,0,'images\pozadi.obr');
            getpal(plt2);
            square(9,9,211,151,15+210);
            for a:=0 to 99 do for b:=0 to 69 do
              case mapa[a,b] of
                   21,22,23,24,0,3,5,6,7,12,13,14,15,38,39,40:box(a*2+10,b*2+10,a*2+11,b*2+11,190);
                   1:box(a*2+10,b*2+10,a*2+11,b*2+11,191);
                   17,36:begin
                     box(a*2+10,b*2+10,a*2+11,b*2+11,191);
                     putpixel(a*2+11,b*2+10,190);
                     end;
                   18,34:begin
                     box(a*2+10,b*2+10,a*2+11,b*2+11,191);
                     putpixel(a*2+11,b*2+11,190);
                     end;
                   19,35:begin
                     box(a*2+10,b*2+10,a*2+11,b*2+11,191);
                     putpixel(a*2+10,b*2+10,190);
                     end;
                   20,37:begin
                     box(a*2+10,b*2+10,a*2+11,b*2+11,191);
                     putpixel(a*2+10,b*2+11,190);
                     end;
                   2,4,25,26,27,28,29,30,31,32,33:box(a*2+10,b*2+10,a*2+11,b*2+11,192);
                   8,9,10,11,16:box(a*2+10,b*2+10,a*2+11,b*2+11,194);
                   end;
          for a:=0 to 99 do for b:=0 to 69 do if spesl[a,b]<>0 then box(a*2+10,b*2+13,a*2+11,b*2+14,193);

          for a:=1 to pocetpnk do begin
              putpixel(xpostava[1,a]*2+9,ypostava[1,a]*2+9,196);
              putpixel(xpostava[1,a]*2+11,ypostava[1,a]*2+11,196);
              putpixel(xpostava[1,a]*2+10,ypostava[1,a]*2+10,196);
              putpixel(xpostava[1,a]*2+9,ypostava[1,a]*2+11,196);
              putpixel(xpostava[1,a]*2+11,ypostava[1,a]*2+9,196);
              end;
          for a:=1 to pocetaln do begin
              putpixel(xpostava[2,a]*2+11,ypostava[2,a]*2+9,195);
              putpixel(xpostava[2,a]*2+9,ypostava[2,a]*2+11,195);
              putpixel(xpostava[2,a]*2+9,ypostava[2,a]*2+9,195);
              putpixel(xpostava[2,a]*2+11,ypostava[2,a]*2+11,195);
              putpixel(xpostava[2,a]*2+10,ypostava[2,a]*2+10,195);
              end;
          square(9,9,211,151,15+210);
          square(10,10,210,150,0+210);
          setblack;
          flip;
          use(vga);
          fadein(4,plt2);
          ukaz_mysku;
          readkey;      }
          schovej_mysku;
          fadeout(4,plt);
          setblack;
          put(nanic,0,0);
          use(vga);
          fadein(4,plt2);
          tahy(1,aktivnipnk);
          mb1:=false;
          smb1:=false;
          ukaz_mysku;
          b:=0;

{          for a:=0 to 30 do for b:=0 to 13 do put_c(sprity[mapa[a+xokolik,b+yokolik]],a*10,b*10);
          for a:=0 to 30 do for b:=-4 to 13 do if spesl[a+xokolik,b+yokolik]<>0 then
              putrle_c(spec[spesl[a+xokolik,b+yokolik]],a*10,b*10);
              for a:=1 to pocetaln do begin
                  if a<>aktivnialn then putrle_c (tvor[2,[9],(xpostava[2,[a]-xokolik)*10,(ypostava[2,a]-yokolik)*10);
                  end;
              for a:=1 to pocetpnk do begin
                  if a<>aktivnipnk then putrle_c (tvor[1,9],(xpostava[1,a]-xokolik)*10,(ypostava[1,a]-yokolik)*10);
                  end;}

          end;
       end;

    end;
end;


if zkazeno=false then begin
if (((lezivhranici (1,141,9,149)) and (mb1)) or((mxx=0) and (my<>0) and (my<>199))) and (xokolik>0) then begin
if (mxx=0) and (my<>0) and (my<>199) and (Bscrolling=false) then else begin
schovej_mysku;
   put_c(sipka,x2*10,y2*10);
for a:=1 to 9 do for b:=141 to 149 do putpixel(a,b,27+getpixel(a,b));
xokolik:=xokolik-1;
zobraz;
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
delay(30);
for a:=1 to 9 do for b:=141 to 149 do putpixel(a,b,getpixel(a,b)-27);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
ukaz_mysku;
end;
end;



if (((lezivhranici (311,1,319,9)) and (mb1)) or ((my=0) and (mxx<>0) and (mxx<>319))) and (yokolik>0)then begin
if (my=0) and (mxx<>0) and (mxx<>319) and (Bscrolling=false) then else begin
schovej_mysku;
   put_c(sipka,x2*10,y2*10);
for a:=311 to 319 do for b:=1 to 9 do putpixel(a,b,27+getpixel(a,b));
yokolik:=yokolik-1;
zobraz;
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
delay(30);
for a:=311 to 319 do for b:=1 to 9 do putpixel(a,b,getpixel(a,b)-27);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
ukaz_mysku;
end;
end;

if (((lezivhranici (311,131,319,139)) and (mb1)) or ((my=199) and (mxx<>0) and (mxx<>319)))and (yokolik<69-13) then begin
if (my=199) and (mxx<>0) and (mxx<>319) and (Bscrolling=false) then else begin
schovej_mysku;
   put_c(sipka,x2*10,y2*10);
for a:=311 to 319 do for b:=131 to 139 do putpixel(a,b,27+getpixel(a,b));
yokolik:=yokolik+1;
zobraz;
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
delay(30);
for a:=311 to 319 do for b:=131 to 139 do putpixel(a,b,getpixel(a,b)-27);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
ukaz_mysku;
end;
end;

if (((lezivhranici (300,141,309,149)) and (mb1)) or((mxx=319) and (my<>0) and (my<>199))) and (xokolik<99-30) then begin
if (mxx=319) and (my<>0) and (my<>199) and (Bscrolling=false) then else begin
schovej_mysku;
   put_c(sipka,x2*10,y2*10);
for a:=300 to 309 do for b:=141 to 149 do putpixel(a,b,27+getpixel(a,b));
xokolik:=xokolik+1;
zobraz;
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
delay(30);
for a:=300 to 309 do for b:=141 to 149 do putpixel(a,b,getpixel(a,b)-27);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
ukaz_mysku;
end;
end;

if ((mxx=319) or (mxx=0)) and ((my=0) or (my=199)) and (bscrolling=true) then begin
schovej_mysku;
put_c(sipka,x2*10,y2*10);
if mxx=0 then xokolik:=xokolik-1 else xokolik:=xokolik+1;
if my=0 then yokolik:=yokolik-1 else yokolik:=yokolik+1;
if xokolik>=99-30 then xokolik:=99-30;
if yokolik>=69-13 then yokolik:=69-13;
if xokolik<=0 then xokolik:=0;
if yokolik<=0 then yokolik:=0;
zobraz;
box(11,141,299,149,248);
box(11+round(1+xokolik*(263/(99-34))),142,19+round(xokolik*(263/(99-34))),148,255);
box(311,11,319,130,248);
box(312,11+round(1+yokolik*(95/(69-20))),318,20+round(yokolik*(95/(69-20))),255);
delay(30);
   get(sipka,x1*10,y1*10,x1*10+10,y1*10+10);
ukaz_mysku;
end;

if (my<140) and (mx<620) and (mb1) and (smb1=false) then begin
   nemuze[xpostava[1,aktivnipnk],ypostava[1,aktivnipnk]+1]:=false;
   nemuze2:=nemuze;
   put_c(sipka,(mx div 20)*10,(my div 10)*10);
   x2:=(mx div 20)+xokolik;
   y2:=(my div 10)+yokolik-1;
   nejdeto:=false;
   if rezim=1 then begin
    nemuze3:=nemuze;
    boolprac:=false;
    d:=vyzkousej(xpostava[1,aktivnipnk],ypostava[1,aktivnipnk],0);
    if d<25 then begin
    g:=xpostava[1,aktivnipnk];
    h:=ypostava[1,aktivnipnk];
    zobraz;
    setclip(0,0,309,139);
    for e:=0 to d-1 do begin
        case cesta[e] of
          2:h:=h+1;
          8:h:=h-1;
          6:g:=g+1;
          4:g:=g-1;
          3:begin
            g:=g+1;
            h:=h+1;
            end;
          1:begin
            g:=g-1;
            h:=h+1;
            end;
          9:begin
            g:=g+1;
            h:=h-1;
            end;
          7:begin
            g:=g-1;
            h:=h-1;
            end;
          end;
        pixely[e]:=getpixel((g-xokolik)*10+5,(h-yokolik)*10+15);
        putpixel_c((g-xokolik)*10+5,(h-yokolik)*10+18,15);
        end;
    delay(200);
    g:=xpostava[1,aktivnipnk];
    h:=ypostava[1,aktivnipnk];
    for e:=0 to d-1 do begin
        case cesta[e] of
          2:h:=h+1;
          8:h:=h-1;
          6:g:=g+1;
          4:g:=g-1;
          3:begin
            g:=g+1;
            h:=h+1;
            end;
          1:begin
            g:=g-1;
            h:=h+1;
            end;
          9:begin
            g:=g+1;
            h:=h-1;
            end;
          7:begin
            g:=g-1;
            h:=h-1;
            end;
          end;
        putpixel_c((g-xokolik)*10+5,(h-yokolik)*10+18,pixely[e]);
    setclip(0,0,319,199);
        end;
    for e:=0 to d-1 do if (tahu[1,aktivnipnk]>0) and (d<30) then jdi(cesta[e],aktivnipnk,1);

    end;
    nemuze:=nemuze2;
    schovej_mysku;
  {  setclip(0,0,309,139);
    put_c(prac[2,aktivnipnk],(xpostava[1,aktivnipnk]-xokolik)*10-20,(ypostava[1,aktivnipnk]-yokolik)*10-pr2okolik);
    putrle_c(tvor[1,9],(xpostava[1,aktivnipnk]-xokolik)*10,(ypostava[1,aktivnipnk]-yokolik)*10);
    setclip(0,0,319,199);}
    zobraz;
    get(sipka,(mx div 20)*10,(my div 10)*10,(mx div 20)*10+10,(my div 10)*10+10);
    square((mx div 20)*10,(my div 10)*10,(mx div 20)*10+10,(my div 10)*10+10,ba[7]);
    nemuze[xpostava[1,aktivnipnk],ypostava[1,aktivnipnk]+1]:=true;
    ukaz_mysku;
    end else begin
      a:=abs(xpostava[1,aktivnipnk]-x2);
      b:=abs(ypostava[1,aktivnipnk]-y2);
      g:=a;
      h:=b;
      if b>a then c:=b else c:=a;
      if (zbran[1,aktivnipnk]=11) then begin
         if (tahu[1,aktivnipnk]>3) then begin
         energie[1,aktivnipnk]:=energie[1,aktivnipnk]+40;
         if energie[1,aktivnipnk]>cenergie[1,aktivnipnk] then energie[1,aktivnipnk]:=cenergie[1,aktivnipnk];
         pk[aktivnipnk,11]:=pk[aktivnipnk,11]-1;
             if pk[aktivnipnk,11]=0 then begin
                zbran[1,aktivnipnk]:=0;
                repeat zbran[1,aktivnipnk]:=zbran[1,aktivnipnk]+1 until (pk[aktivnipnk,zbran[1,aktivnipnk]]>0)
                       or (zbran[1,aktivnipnk]>=20);
                if zbran[1,aktivnipnk]>=20 then zbran[1,aktivnipnk]:=0;
                end;
         zbrane(aktivnipnk);
         tahu[1,aktivnipnk]:=tahu[1,aktivnipnk]-4;
         tahy(1,aktivnipnk);
         end;
         end else
      if (dosah[zbran[1,aktivnipnk]]>=c) and (tahu[1,aktivnipnk]>=akcnich_bodu[zbran[1,aktivnipnk]])
                 and (zbran[1,aktivnipnk]>0) then STRELA(1,AKTIVNIPNK)
                 else begin
                 get(nanic,80,70,240,80);
                 if tahu[1,aktivnipnk]<akcnich_bodu[zbran[1,aktivnipnk]] then print_fc(90,70,ba[15],'Nem*# dost ak$n(ch bod".',
                    false) else if zbran[1,aktivnipnk]=0 then print_fc(100,70,ba[15],'Nem*# ^*dn) zbran@ !',false)
                   else print_fc(90,70,ba[15],'C(l nen( v dosahu zbran@.',false);
                 init1('sounds\fuckyou.wav');
                 play1;
                 put(nanic,80,70);

          end;

      setclip(0,0,319,199);
      end;
      end;



if keypressed then begin
ch:=readkey;
{case ch of
  '8': if kontrola8=false then jdi(8,aktivnipnk);
  '2': if kontrola2=false then jdi(2,aktivnipnk);
  '6': if kontrola6=false then jdi(6,aktivnipnk);
  '4': if kontrola4=false then jdi(4,aktivnipnk);
  '9': if kontrola9=false then jdi(9,aktivnipnk);
  '7': if kontrola7=false then jdi(7,aktivnipnk);
  '3': if kontrola3=false then jdi(3,aktivnipnk);
  '1': if kontrola1=false then jdi(1,aktivnipnk);
end;
while keypressed do readkey;
    schovej_mysku;
    setclip(0,0,309,139);
    put_c(prac[2,aktivnipnk],(xpostava[1,aktivnipnk]-xokolik)*10-20,(ypostava[1,aktivnipnk]-yokolik)*10-pr2okolik);
    putrle_c(tvor[1,9],(xpostava[1,aktivnipnk]-xokolik)*10,(ypostava[1,aktivnipnk]-yokolik)*10);
    setclip(0,0,319,199);
    ukaz_mysku;}
end;
end;
until ch=#27;
if ch=#27 then ch:=#69;
ukaz_mysku;
schovej_mysku;
if vsehotovo=false then begin
getpal(plt3);
fadeout(4,plt3);
cls(0);
setblack;
use(virt);
end;
end;

procedure zobraz_nastaveni;
begin
           schovej_mysku;
           if bzvuky then begin
              line(41,80,45,84,12,false);
              line(45,80,41,84,12,false);
              end else box (41,80,45,84,0);
           if bhlasky then begin
              line(41,95,45,99,12,false);
              line(45,95,41,99,12,false);
              end else box (41,95,45,99,0);
           if bdialogy then begin
              line(41,110,45,114,12,false);
              line(45,110,41,114,12,false);
              end else box (41,110,45,114,0);
           if bscrolling then begin
              line(41,125,45,129,12,false);
              line(45,125,41,129,12,false);
              end else box (41,125,45,129,0);
              ukaz_mysku;
end;


begin
initvga;
getpal(zaklpal);
loadfont('fonts\pavel.fn');
(*cls(0);
use(virt);
loadpcx(0,0,'images\albisoft.obr');
loadpcx(0,0,'images\alb1.obr');
for a:=0 to 3 do get(titulky[a],0,a*40,319,a*40+39);{51}
get(titulky[4],0,160,190,199);
get(titulky[5],199,160,202,199);
loadpcx(0,0,'images\alb2.obr');
for a:=0 to 4 do get(titulky[a+6],0,a*40,319,a*40+39);{51}
getpal(plt);
{setblack;
{flip;}
use(vga);
a:=0;
d:=320;
c:=0;
e:=0;
repeat
delay(30+(e*5));
box(0,80,319,120,0);
if c=0 then a:=a+1 else a:=a-1;
if a>10 then begin
   a:=9;
   c:=1;
   end;
if a<0 then begin
   a:=1;
   c:=0;
   e:=e+1;
   end;
if a>5 then b:=5-(a-5) else b:=a;
d:=d-3;
if e<>12 then put_c(titulky[a],160-125+(b*25)+d,81){ else put_c(titulky[0],35,80)};
until (keypressed) or (e=12);
cls(0);
use(virt);
loadpcx(0,0,'images\asoft2.obr');
flip;

delay(1000);                 *)
{use(virt);}
cls(0);
loadpcx(0,0,'images\albisoft.obr');
{for a:=0 to 99 do begin
    get(nanic,0,a,319,a);
    get(nanic2,0,199-a,319,199-a);
    use(vga);
    put(nanic,0,a);
    put(nanic2,0,199-a);
    delay(8);
    use(virt);
    end;}
{flip;
use(vga);}
getpal(plt);
{setblack;
flip;}
(*for a:=0 to 320 do begin
    for b:=0 to 99 do begin
        use(virt);
        c:=getpixel(a,b*2);
        d:=getpixel(319-a,b*2+1);
        use(vga);
        putpixel(a,b*2,c);
        putpixel(319-a,b*2+1,d);
        end;
{    delay(10);}
    end;*)
{fadein(4,plt);}
{for a:=1 to 65 do killsprite(titulky[a]);}

cekej(8000);
for a:=1 to 320 do begin
    for b:=0 to 100 do begin
        putpixel(a,b*2,0);
        putpixel(319-a,b*2+1,0);
        end;
    delay(3);
    end;
use(virt);
cls(0);
loadpcx(135,80,'images\uvadi.obr');
getpal(plt);
setblack;
flip;
use(vga);
fadein(4,plt);
cekej(4000);
fadeout(4,plt);
{for a:=135 to 320 do begin
    for b:=0 to 100 do begin
        putpixel(a,b*2,0);
        putpixel(319-a,b*2+1,0);
        end;
    delay(3);
    end;}
intro;
cls(0);
use(virt);
loadpcx(0,0,'images\alnlogo.obr');
for a:=80 to 170 do setcolor(a,0,0,0);
for a:=0 to 319 do for b:=0 to 199 do putpixel(a,b,getpixel(a,b)+80);
flip;
use(vga);
randseed:=30;
for a:=1 to 1280 do begin
    for e:=1 to 50 do begin
    b:=0;
    while b<80 do begin
    c:=random(320);
    d:=random(200);
    b:=getpixel(c,d);
    end;
    putpixel(c,d,b-80);
    end;
    delay(1);
    end;
{while keypressed=false do begin
      init1('sounds\music.wav');
      play1;
      end;}
while keypressed do readkey;
readkey;
getpal(plt);
fadeout(4,plt);

cls(0);
{loadpcx(0,0,'back.obr');
readkey;
cls(0); }
randomize;
use(virt);
cls(0);
loadpcx(0,0,'images\hm7.obr');
getpal(plt2);
for a:=0 to 31 do begin
    get(sprity[a],a*10,0,a*10+9,9);
    end;
for a:=0 to 23 do begin
    get(sprity[a+32],a*10,10,a*10+9,19);
    end;
sprity[0]:=sprity[38];
for a:=0 to 19 do get(tvor[1,a+1],a*10,80,a*10+9,100);
for a:=0 to 19 do get(tvor[3,a+1],a*10+160,80,a*10+169,100);
for a:=0 to 19 do get(tvor[2,a+1],a*10,110,a*10+9,130);
get(tvor[1,21],200,95,225,101);
get(tvor[2,21],200,123,221,130);
for a:=1 to 21 do makerle(tvor[1,a]);
for a:=1 to 21 do makerle(tvor[2,a]);
get(spec[1],0,20,20,57);
get(spec[2],21,20,42,56);
get(spec[3],43,20,58,71);
get(spec[4],59,20,88,42);
get(spec[5],89,20,124,61);
get(spec[6],125,20,139,52);
get(spec[7],140,20,152,49);
get(spec[8],153,20,163,31);
get(spec[9],164,20,183,36);
get(spec[10],184,20,193,47);
get(spec[11],194,20,203,39);
get(spec[12],204,20,213,47);
for a:=1 to 12 do makerle(spec[a]);
get(sprsipka,310,10,319,19);
makerle(sprsipka);
get(sprlogo,250,170,272,192);
for a:=0 to 6 do get(sprtlacitko[a],a*8,171,a*8+7,178);
{54,78,24}
for a:=0 to 2 do get(sprtlacitko[a+7],55+a*25,171,77+a*25,178);
for a:=0 to 9 do makerle(sprtlacitko[a]);
repeat
cls(0);
loadpcx(0,0,'images\hlmenuX.obr');
for a:=1 to 5 do get(tlacitka[a],0,(a-1)*16+3,169,(a-1)*16+18);
for a:=1 to 5 do get(stlacena[a],0,(a-1)*16+88,169,(a-1)*16+103);
for a:=1 to 6 do get(znak[a],170,(a-1)*20,185,(a-1)*20+19);
for a:=1 to 6 do makerle(znak[a]);
cls(0);

loadpcx(0,0,'images\menu.obr');
for a:=1 to 5 do put(tlacitka[a],80,(a-1)*16+98);
getpal(plt);
setblack;
flip;
use(vga);
fadein(4,plt);
b:=0;
c:=1;
assign(fnast,'setup.sp');
reset(fnast);
read(fnast,uh1);
if uh1=1 then bzvuky:=true else bzvuky:=false;
read(fnast,uh1);
if uh1=1 then bhlasky:=true else bhlasky:=false;
read(fnast,uh1);
if uh1=1 then bdialogy:=true else bdialogy:=false;
read(fnast,uh1);
if uh1=1 then bscrolling:=true else bscrolling:=false;
close(fnast);
get(nanic,60,(c-1)*16+97,80,(c-1)*16+98+15);
get(nanic2,250,(c-1)*16+97,270,(c-1)*16+98+15);
muzes:=false;
ukaz_mysku;
repeat
smx:=mx;
smy:=my;
smb1:=mb1;
smb2:=mb2;
pozice_mysky (mx,my,mb1,mb2,mbnanic);
mxx:=mx div 2;
smxx:=smx div 2;
for a:=1 to 5 do begin
    if (lezivhranici(80,(a-1)*16+98,250,(a-1)*16+95+18))
       and (lezelvhranici(80,(a-1)*16+98,250,(a-1)*16+95+18)=false) then begin
       schovej_mysku;
       put(stlacena[a],80,(a-1)*16+98);
       put(nanic,60,(c-1)*16+97);
       put(nanic2,250,(c-1)*16+97);
       c:=a;
       get(nanic,60,(c-1)*16+97,79,(c-1)*16+98+15);
       get(nanic2,250,(c-1)*16+97,269,(c-1)*16+98+15);
       ukaz_mysku;
       end;
    if (lezivhranici(80,(a-1)*16+98,250,(a-1)*16+95+18)) and (mb1) and (smb1=false) then begin
       schovej_mysku;
       put(stlacena[a],81,(a-1)*16+99);
       square(80,(a-1)*16+98,80+167,a*16+97,ba[7]);
       ukaz_mysku;
       c:=a;
       end;
    if (lezivhranici(80,(a-1)*16+98,250,(a-1)*16+95+18)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       put(tlacitka[a],80,(a-1)*16+98);
       ukaz_mysku;
       case a of
       1:muzes:=true;
       2:begin
          schovej_mysku;
         getpal(plt3);
         get(bnanic,0,0,319,199);
         intro;
         cls(0);
         setpal(plt3);
         put(bnanic,0,0);
         nastav_mysku(mx,my);
         killsprite(bnanic);
         mb1:=false;
         smb1:=false;
         ukaz_mysku;
         a:=2;
         b:=0;
         c:=2;
         end;
       3:begin
         schovej_mysku;
         getpal(plt3);
         get(bnanic,0,0,319,199);
       ukazsetap;
         loadpcx(0,0,'images\setap2.obr');
         get(stlacena2,0,0,99,19);
         loadpcx(0,0,'images\setap.obr');
         zobraz_nastaveni;
         get(tlacitka2,110,150,210,170);
         getpal(plt);
         setblack;
         flip;
         fadein(4,plt);
         use(vga);
         ukaz_mysku;

repeat
smx:=mx;
smy:=my;
smb1:=mb1;
smb2:=mb2;
pozice_mysky (mx,my,mb1,mb2,mbnanic);
mxx:=mx div 2;
smxx:=smx div 2;
    if (lezivhranici(110,150,210,170))
       and ((lezelvhranici(110,150,210,170)=false)) then begin
       schovej_mysku;
       put(stlacena2,110,150);
       ukaz_mysku;
       end;
    if (lezivhranici(110,150,210,170)) and (mb1) and (smb1=false) then begin
       schovej_mysku;
       put(stlacena2,110+1,151);
       square(110,150,210,170,254);
       ukaz_mysku;
       end;
    if (lezivhranici(110,150,210,170)) and (mb1=false) and (smb1) then begin
       schovej_mysku;
       put(tlacitka2,110,150);
       muzes:=true;
       ukaz_mysku;
       end;
    if (lezelvhranici(110,150,210,170))
       and (lezivhranici(110,150,210,170)=false) then begin
       schovej_mysku;
       put(tlacitka2,110,150);
       ukaz_mysku;
    end;

    for a:=1 to 4 do begin
        if (mb1=true) and (smb1=false) and (lezivhranici(38,(a-1)*15+77,49,(a-1)*15+88)) then begin
           if a=1 then Bzvuky:=not Bzvuky;
           if a=2 then Bhlasky:=not Bhlasky;
           if a=3 then Bdialogy:=not Bdialogy;
           if a=4 then Bscrolling:=not Bscrolling;
           zobraz_nastaveni;
           end;
        end;
until muzes;
         schovej_mysku;
         fadeout(4,plt);
         use(vga);
         cls(0);
         setblack;
         put(bnanic,0,0);
         fadein(4,plt3);
         nastav_mysku(mx,my);
         killsprite(bnanic);
         mb1:=false;
         smb1:=false;
         ukaz_mysku;
         a:=0;
         b:=0;
         c:=3;
         smb1:=false;
         mb1:=false;
         muzes:=false;
         end;
       4:kredity;
       5:begin
         assign(fnast,'setup.sp');
         rewrite(fnast);
         uh1:=1;
         uh2:=0;
         if bzvuky then write(fnast,uh1) else write(fnast,uh2);
         if bhlasky then write(fnast,uh1) else write(fnast,uh2);
         if bdialogy then write(fnast,uh1) else write(fnast,uh2);
         if bscrolling then write(fnast,uh1) else write(fnast,uh2);
         close(fnast);
         halt;
         end;
       end;
       end;
    if (lezelvhranici(80,(a-1)*16+98,250,(a-1)*16+95+18))
       and (lezivhranici(80,(a-1)*16+98,250,(a-1)*16+95+18)=false) then begin
       schovej_mysku;
       put(tlacitka[a],80,(a-1)*16+98);
       ukaz_mysku;
       end;
    end;
delay(40);
b:=b+1;
if b>11 then b:=2;
if (mxx>50) and (my>(c-1)*16+80) and (mxx<80) and (my<(c-1)*16+97+20) then begin
   schovej_mysku;
   end;
if (mxx>240) and (my>(c-1)*16+80) and (mxx<270) and (my<(c-1)*16+97+20) then begin
   schovej_mysku;
   end;
if b<7 then begin
   put(nanic,60,(c-1)*16+97);
   put(nanic2,250,(c-1)*16+97);
   putrle(znak[b],60,(c-1)*16+97);
   putrle(znak[b],250,(c-1)*16+97);
   end else begin
       put(nanic,60,(c-1)*16+97);
       put(nanic2,250,(c-1)*16+97);
       putrle(znak[12-b],60,(c-1)*16+97);
       putrle(znak[12-b],250,(c-1)*16+97);
       end;
if (mxx>50) and (my>(c-1)*16+80) and (mxx<80) and (my<(c-1)*16+97+20) then ukaz_mysku;
if (mxx>240) and (my>(c-1)*16+80) and (mxx<270) and (my<(c-1)*16+97+20) then begin
   ukaz_mysku;
   end;
until muzes;
schovej_mysku;
getpal(plt);
fadeout(4,plt);
pomocna;
getpal(plt);
setblack;
flip;
use(vga);
fadein(4,plt);
while keypressed do readkey;
jmeno:='';
print_fc(78,115,14,jmeno+'_',false);
repeat
ch:=readkey;
if ord(ch)=0 then begin
   ch:=readkey;
   if (ord(ch)=331-256) then begin
      st:=jmeno;
      jmeno:='';
      for a:=1 to length(st)-1 do jmeno:=jmeno+st[a];
      end;
   end else if ord(ch)=8 then begin
      st:=jmeno;
      jmeno:='';
      for a:=1 to length(st)-1 do jmeno:=jmeno+st[a];
      end else if (length(jmeno)<8) and (ord(ch)>31) and (ord(ch)<123) then begin
          if (ch<>' ') and (ch<>'.') and (ch<>',') and (ch<>':') and (ch<>'?') then
          jmeno:=jmeno+ch;
          end;
   box(75,115,244,124,0);
   print_fc(78,115,14,jmeno+'_',false);
until ch=#13;
getpal(plt);
fadeout(4,plt);
setblack;
penez:=2000;
repeat
cls(0);
level;
if uroven<>0 then hra;

until (uroven=0) or (vsehotovo);
if vsehotovo=false then begin
getpal(plt);
fadeout(4,plt);
end;
if vsehotovo then vsehotovo:=false;
cls(0);
setblack;
use(virt);
until b=32000;
end.
