Advertisement
anotender

gra_statki

Dec 17th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 92.76 KB | None | 0 0
  1. program project1;
  2.  
  3. uses wincrt,wingraph,sysutils;
  4.  
  5. type statek=record
  6.   dlugosc:word;
  7.   orientacja:word;//1-pion;2-poziom
  8. end;
  9.  
  10. type pole=record
  11.   tmp:word;
  12.   stale:word;
  13. end;
  14.  
  15. var
  16.   driver,mode:smallint;
  17.  
  18. const
  19.   szerokosc=25;
  20.  
  21.   {===============
  22.    0-puste pole
  23.    1-statek nie trafiony
  24.    2-pudlo
  25.    3-statek trafiony
  26.    4-wybierany
  27.    ===============}
  28.  
  29. procedure rysuj(plansza:array of pole;x,y:smallint); //parametry zaznaczone okreslaja ktore pole jest aktualnie wskazywane przez uzytkownika
  30. var
  31.   i,j:word;
  32.   x1,y1:smallint;
  33. begin
  34.   x1:=szerokosc+szerokosc div 3+x;
  35.   y1:=szerokosc+szerokosc div 2+y;
  36.  
  37.   settextstyle(0,0,1);
  38.  
  39.   for i:=1 to 10 do
  40.   begin
  41.     outtextxy(x1+i*szerokosc,y1,inttostr(i));
  42.   end;
  43.   for i:=1 to 10 do
  44.   begin
  45.     outtextxy(x1,y1+i*szerokosc,chr(i+64));
  46.   end;
  47.  
  48.   x1:=2*szerokosc+x;
  49.   y1:=2*szerokosc+y;
  50.  
  51.   for i:=0 to 9 do
  52.   begin
  53.     for j:=0 to 9 do
  54.     begin
  55.       if plansza[j+i*10].tmp=4 then
  56.       begin
  57.         setfillstyle(solidfill,yellow);
  58.         bar(x1+j*szerokosc,y1+i*szerokosc,x1+(j+1)*szerokosc,y1+(i+1)*szerokosc);
  59.         setfillstyle(solidfill,white);
  60.         continue;
  61.       end;
  62.       if plansza[j+i*10].stale=2 then
  63.       begin
  64.         bar(x1+j*szerokosc,y1+i*szerokosc,x1+(j+1)*szerokosc,y1+(i+1)*szerokosc);
  65.         continue;
  66.       end;
  67.       if plansza[j+i*10].stale=3 then
  68.       begin
  69.         setfillstyle(solidfill,red);
  70.         bar(x1+j*szerokosc,y1+i*szerokosc,x1+(j+1)*szerokosc,y1+(i+1)*szerokosc);
  71.         setfillstyle(solidfill,white);
  72.         continue;
  73.       end;
  74.       rectangle(x1+j*szerokosc,y1+i*szerokosc,x1+(j+1)*szerokosc,y1+(i+1)*szerokosc);
  75.  
  76.     end;
  77.   end;
  78. end;
  79.  
  80. procedure obrysowanie(var plansza:array of pole;orientacja,dlugosc,i,j:word);
  81. var
  82.   l,k,iterator:word;
  83. begin
  84.   if orientacja=1 then
  85.               begin
  86.                 l:=j-1;
  87.                 if j=0 then
  88.                 begin
  89.                   if i=0 then
  90.                   begin
  91.                     for iterator:=i to dlugosc+i do
  92.                     begin
  93.                       plansza[j+1+iterator*10].stale:=2;
  94.                     end;
  95.                   end
  96.                   else
  97.                   begin
  98.                     for iterator:=i-1 to dlugosc+i do
  99.                     begin
  100.                       plansza[j+1+iterator*10].stale:=2;
  101.                     end;
  102.                   end;
  103.                 end
  104.                 else if j=9 then
  105.                 begin
  106.                   if i=0 then
  107.                   begin
  108.                     for iterator:=i to dlugosc+i do
  109.                     begin
  110.                       plansza[j-1+iterator*10].stale:=2;
  111.                     end;
  112.                   end
  113.                   else
  114.                   begin
  115.                     for iterator:=i-1 to dlugosc+i do
  116.                     begin
  117.                       plansza[j-1+iterator*10].stale:=2;
  118.                     end;
  119.                   end;
  120.                 end
  121.                 else
  122.                 begin
  123.                   if i=0 then
  124.                   begin
  125.                     for k:=i to dlugosc+i do
  126.                     begin
  127.                       plansza[j+1+k*10].stale:=2;
  128.                       plansza[j-1+k*10].stale:=2;
  129.                     end;
  130.                     plansza[j+(dlugosc+i)*10].stale:=2;
  131.                   end
  132.                   else if i+dlugosc-1=9 then
  133.                   begin
  134.                     for k:=i-1 to dlugosc+i-1 do
  135.                     begin
  136.                       plansza[j+1+k*10].stale:=2;
  137.                       plansza[j-1+k*10].stale:=2;
  138.                     end;
  139.                     plansza[j+(i-1)*10].stale:=2;
  140.                   end
  141.                   else
  142.                   begin
  143.                     while l<=j+1 do
  144.                     begin
  145.                       for k:=i-1 to dlugosc+i do
  146.                       begin
  147.                         plansza[l+k*10].stale:=2;
  148.                       end;
  149.                     l:=l+2;
  150.                     end;
  151.                   end;
  152.                 end;
  153.                 if i>0 then plansza[j+(i-1)*10].stale:=2;
  154.                 if i+dlugosc<10 then plansza[j+(dlugosc+i)*10].stale:=2;
  155.                 {for iterator:=i to dlugosc-1+i do
  156.                 begin
  157.                   plansza[j+iterator*10].stale:=3;
  158.                 end;}
  159.               end
  160.               else
  161.               begin
  162.                 k:=i-1;
  163.                 if i=0 then
  164.                 begin
  165.                   if j+dlugosc=10 then
  166.                   begin
  167.                     for l:=j-1 to dlugosc+j-1 do
  168.                     begin
  169.                       plansza[l+(i+1)*10].stale:=2;
  170.                     end;
  171.                   end
  172.                   else if j=0 then
  173.                   begin
  174.                     for l:=j to dlugosc+j do
  175.                     begin
  176.                       plansza[l+(i+1)*10].stale:=2;
  177.                     end;
  178.                   end
  179.                   else
  180.                   begin
  181.                     for l:=j-1 to dlugosc+j do
  182.                     begin
  183.                       plansza[l+(i+1)*10].stale:=2;
  184.                     end;
  185.                   end;
  186.                 end
  187.                 else if i=9 then
  188.                 begin
  189.                   if j=0 then
  190.                   begin
  191.                     for l:=j to dlugosc+j do
  192.                     begin
  193.                       plansza[l+(i-1)*10].stale:=2;
  194.                     end;
  195.                     plansza[j+dlugosc+i*10].stale:=2;
  196.                   end
  197.                   else if j+dlugosc-1=9 then
  198.                   begin
  199.                     for l:=j-1 to dlugosc+j-1 do
  200.                     begin
  201.                       plansza[l+(i-1)*10].stale:=2;
  202.                     end;
  203.                     plansza[j+i*10].stale:=2;
  204.                   end
  205.                   else
  206.                   begin
  207.                     for l:=j-1 to dlugosc+j do
  208.                     begin
  209.                       plansza[l+(i-1)*10].stale:=2;
  210.                     end;
  211.                     plansza[j+dlugosc+i*10].stale:=2;
  212.                     plansza[j-1+i*10].stale:=2;
  213.                   end;
  214.                 end
  215.                 else
  216.                 begin
  217.                   if j+dlugosc=10 then
  218.                   begin
  219.                     while k<=i+1 do
  220.                     begin
  221.                       for l:=j-1 to dlugosc+j-1 do
  222.                       begin
  223.                         plansza[l+k*10].stale:=2;
  224.                       end;
  225.                     k:=k+2;
  226.                     end;
  227.                   end
  228.                   else if j=0 then
  229.                   begin
  230.                     while k<=i+1 do
  231.                     begin
  232.                       for l:=j to dlugosc+j do
  233.                       begin
  234.                         plansza[l+k*10].stale:=2;
  235.                       end;
  236.                     k:=k+2;
  237.                     end;
  238.                   end
  239.                   else
  240.                   begin
  241.                     while k<=i+1 do
  242.                     begin
  243.                       for l:=j-1 to dlugosc+j do
  244.                       begin
  245.                         plansza[l+k*10].stale:=2;
  246.                       end;
  247.                     k:=k+2;
  248.                     end;
  249.                   end;
  250.                 end;
  251.                 if j>0 then plansza[j-1+i*10].stale:=2;
  252.                 if j+dlugosc<10 then plansza[j+dlugosc+i*10].stale:=2;
  253.                 {for iterator:=j to dlugosc-1+j do
  254.                 begin
  255.                   plansza[iterator+i*10].stale:=3;
  256.                 end;}
  257.               end;
  258. end;
  259.  
  260. function czy_zatopiony(var plansza:array of pole;i,j:word):boolean;
  261. var
  262.   dlugosc1,dlugosc2,orientacja,iterator:word;
  263.   trafiony_zatopiony:boolean;
  264. begin
  265.   orientacja:=0;
  266.   if j=0 then
  267.   begin
  268.     if i=0 then
  269.     begin
  270.       if (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  271.       begin
  272.         orientacja:=1;
  273.       end
  274.       else if (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  275.       begin
  276.         orientacja:=2;
  277.       end
  278.       else
  279.       begin
  280.         settextstyle(defaultfont,horizdir,2);
  281.         outtextxy(0,0,'Trafiony-zatopiony');
  282.         obrysowanie(plansza,1,1,i,j);
  283.         czy_zatopiony:=true;
  284.         delay(750);
  285.         //cleardevice;
  286.         exit;
  287.       end;
  288.     end
  289.     else if i=9 then
  290.     begin
  291.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) then
  292.       begin
  293.         orientacja:=1;
  294.       end
  295.       else if (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  296.       begin
  297.         orientacja:=2;
  298.       end
  299.       else
  300.       begin
  301.         settextstyle(defaultfont,horizdir,2);
  302.         outtextxy(0,0,'Trafiony-zatopiony');
  303.         obrysowanie(plansza,1,1,i,j);
  304.         czy_zatopiony:=true;
  305.         delay(750);
  306.         //cleardevice;
  307.         exit;
  308.       end;
  309.     end
  310.     else
  311.     begin
  312.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) or (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  313.       begin
  314.         orientacja:=1;
  315.       end
  316.       else if (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  317.       begin
  318.         orientacja:=2;
  319.       end
  320.       else
  321.       begin
  322.         settextstyle(defaultfont,horizdir,2);
  323.         outtextxy(0,0,'Trafiony-zatopiony');
  324.         obrysowanie(plansza,1,1,i,j);
  325.         czy_zatopiony:=true;
  326.         delay(750);
  327.         //cleardevice;
  328.         exit;
  329.       end;
  330.     end;
  331.   end
  332.   else if j=9 then
  333.   begin
  334.     if i=0 then
  335.     begin
  336.       if (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  337.       begin
  338.         orientacja:=1;
  339.       end
  340.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) then
  341.       begin
  342.         orientacja:=2;
  343.       end
  344.       else
  345.       begin
  346.         settextstyle(defaultfont,horizdir,2);
  347.         outtextxy(0,0,'Trafiony-zatopiony');
  348.         obrysowanie(plansza,1,1,i,j);
  349.         czy_zatopiony:=true;
  350.         delay(750);
  351.         //cleardevice;
  352.         exit;
  353.       end;
  354.     end
  355.     else if i=9 then
  356.     begin
  357.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) then
  358.       begin
  359.         orientacja:=1;
  360.       end
  361.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) then
  362.       begin
  363.         orientacja:=2;
  364.       end
  365.       else
  366.       begin
  367.         settextstyle(defaultfont,horizdir,2);
  368.         outtextxy(0,0,'Trafiony-zatopiony');
  369.         obrysowanie(plansza,1,1,i,j);
  370.         czy_zatopiony:=true;
  371.         delay(750);
  372.         //cleardevice;
  373.         exit;
  374.       end;
  375.     end
  376.     else
  377.     begin
  378.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) or (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  379.       begin
  380.         orientacja:=1;
  381.       end
  382.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) then
  383.       begin
  384.         orientacja:=2;
  385.       end
  386.       else
  387.       begin
  388.         settextstyle(defaultfont,horizdir,2);
  389.         outtextxy(0,0,'Trafiony-zatopiony');
  390.         obrysowanie(plansza,1,1,i,j);
  391.         czy_zatopiony:=true;
  392.         delay(750);
  393.         //cleardevice;
  394.         exit;
  395.       end;
  396.     end;
  397.   end
  398.   else
  399.   begin
  400.     if i=0 then
  401.     begin
  402.       if (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  403.       begin
  404.         orientacja:=1;
  405.       end
  406.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) or (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  407.       begin
  408.         orientacja:=2;
  409.       end
  410.       else
  411.       begin
  412.         settextstyle(defaultfont,horizdir,2);
  413.         outtextxy(0,0,'Trafiony-zatopiony');
  414.         obrysowanie(plansza,1,1,i,j);
  415.         czy_zatopiony:=true;
  416.         delay(750);
  417.         //cleardevice;
  418.         exit;
  419.       end;
  420.     end
  421.     else if i=9 then
  422.     begin
  423.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) then
  424.       begin
  425.         orientacja:=1;
  426.       end
  427.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) or (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  428.       begin
  429.         orientacja:=2;
  430.       end
  431.       else
  432.       begin
  433.         obrysowanie(plansza,1,1,i,j);
  434.         settextstyle(defaultfont,horizdir,2);
  435.         outtextxy(0,0,'Trafiony-zatopiony');
  436.         czy_zatopiony:=true;
  437.         delay(750);
  438.         //cleardevice;
  439.         exit;
  440.       end;
  441.     end
  442.     else
  443.     begin
  444.       if (plansza[j+(i-1)*10].stale=1) or (plansza[j+(i-1)*10].stale=3) or (plansza[j+(i+1)*10].stale=1) or (plansza[j+(i+1)*10].stale=3) then
  445.       begin
  446.         orientacja:=1;
  447.       end
  448.       else if (plansza[j-1+i*10].stale=1) or (plansza[j-1+i*10].stale=3) or (plansza[j+1+i*10].stale=1) or (plansza[j+1+i*10].stale=3) then
  449.       begin
  450.         orientacja:=2;
  451.       end
  452.       else
  453.       begin
  454.         settextstyle(defaultfont,horizdir,2);
  455.         outtextxy(0,0,'Trafiony-zatopiony');
  456.         obrysowanie(plansza,1,1,i,j);
  457.         czy_zatopiony:=true;
  458.         delay(750);
  459.         //cleardevice;
  460.         exit;
  461.       end;
  462.     end;
  463.   end;
  464.   if orientacja=1 then
  465.   begin
  466.     dlugosc1:=0;
  467.     dlugosc2:=0;
  468.     if i=0 then
  469.     begin
  470.       for iterator:=i to 9 do
  471.       begin
  472.         if (plansza[j+iterator*10].stale=1)or(plansza[j+iterator*10].stale=3) then
  473.         begin
  474.           inc(dlugosc1);
  475.         end
  476.         else
  477.         begin
  478.           break;
  479.         end;
  480.       end;
  481.     end
  482.                 else if i=9 then
  483.                 begin
  484.                 for iterator:=i downto 0 do
  485.                 begin
  486.                   if (plansza[j+iterator*10].stale=1)or(plansza[j+iterator*10].stale=3) then
  487.                   begin
  488.                     inc(dlugosc2);
  489.                   end
  490.                   else
  491.                   begin
  492.                     break;
  493.                   end;
  494.                 end;
  495.                 i:=i-dlugosc2+1;
  496.                 end
  497.                 else
  498.                 begin
  499.  
  500.                 for iterator:=i to 9 do
  501.                 begin
  502.                   if (plansza[j+iterator*10].stale=1)or(plansza[j+iterator*10].stale=3) then
  503.                   begin
  504.                     inc(dlugosc1);
  505.                   end
  506.                   else
  507.                   begin
  508.                     break;
  509.                   end;
  510.                 end;
  511.  
  512.                 for iterator:=i downto 0 do
  513.                 begin
  514.                   if (plansza[j+iterator*10].stale=1)or(plansza[j+iterator*10].stale=3) then
  515.                   begin
  516.                     inc(dlugosc2);
  517.                   end
  518.                   else
  519.                   begin
  520.                     break;
  521.                   end;
  522.                 end;
  523.                 i:=i-dlugosc2+1;
  524.                 end;
  525.  
  526.  
  527.                 trafiony_zatopiony:=true;
  528.                 for iterator:=i to i+dlugosc1+dlugosc2-2 do
  529.                 begin
  530.                   if plansza[j+iterator*10].stale<>3 then
  531.                   begin
  532.                     trafiony_zatopiony:=false;
  533.                     break;
  534.                   end;
  535.                 end;
  536.                 if trafiony_zatopiony then
  537.                 begin
  538.                   czy_zatopiony:=true;
  539.                   obrysowanie(plansza,orientacja,dlugosc1+dlugosc2-1,i,j);
  540.                   settextstyle(defaultfont,horizdir,2);
  541.                   outtextxy(0,0,'Trafiony-zatopiony');
  542.                   delay(750);
  543.                   //cleardevice;
  544.                 end
  545.                 else
  546.                 begin
  547.                   czy_zatopiony:=false;
  548.                   settextstyle(defaultfont,horizdir,2);
  549.                   outtextxy(0,0,'Trafiony');
  550.                   delay(750);
  551.                   //cleardevice;
  552.                 end;
  553.               end
  554.               else
  555.               begin
  556.                 dlugosc1:=0;
  557.                 dlugosc2:=0;
  558.                 if j=0 then
  559.                 begin
  560.                 for iterator:=j to 9 do
  561.                 begin
  562.                   if (plansza[iterator+i*10].stale=1)or(plansza[iterator+i*10].stale=3) then
  563.                   begin
  564.                     inc(dlugosc1);
  565.                   end
  566.                   else
  567.                   begin
  568.                     break;
  569.                   end;
  570.                 end;
  571.  
  572.                 end
  573.                 else if j=9 then
  574.                 begin
  575.                 for iterator:=j downto 0 do
  576.                 begin
  577.                   if (plansza[iterator+i*10].stale=1)or(plansza[iterator+i*10].stale=3) then
  578.                   begin
  579.                     inc(dlugosc2);
  580.                   end
  581.                   else
  582.                   begin
  583.                     break;
  584.                   end;
  585.                 end;
  586.                 j:=j-dlugosc2+1;
  587.                 end
  588.                 else
  589.                 begin
  590.                 for iterator:=j to 9 do
  591.                 begin
  592.                   if (plansza[iterator+i*10].stale=1)or(plansza[iterator+i*10].stale=3) then
  593.                   begin
  594.                     inc(dlugosc1);
  595.                   end
  596.                   else
  597.                   begin
  598.                     break;
  599.                   end;
  600.                 end;
  601.  
  602.                 for iterator:=j downto 0 do
  603.                 begin
  604.                   if (plansza[iterator+i*10].stale=1)or(plansza[iterator+i*10].stale=3) then
  605.                   begin
  606.                     inc(dlugosc2);
  607.                   end
  608.                   else
  609.                   begin
  610.                     break;
  611.                   end;
  612.  
  613.                 end;
  614.                 j:=j-dlugosc2+1;
  615.                 end;
  616.  
  617.  
  618.                 trafiony_zatopiony:=true;
  619.                 for iterator:=j to j+dlugosc1+dlugosc2-2 do
  620.                 begin
  621.                   if plansza[iterator+i*10].stale<>3 then
  622.                   begin
  623.                     trafiony_zatopiony:=false;
  624.                     break;
  625.                   end;
  626.                 end;
  627.                 if trafiony_zatopiony then
  628.                 begin
  629.                   czy_zatopiony:=true;
  630.                   obrysowanie(plansza,orientacja,dlugosc1+dlugosc2-1,i,j);
  631.                   settextstyle(defaultfont,horizdir,2);
  632.                   outtextxy(0,0,'Trafiony-zatopiony');
  633.                   delay(750);
  634.                   //cleardevice;
  635.                 end
  636.                 else
  637.                 begin
  638.                   czy_zatopiony:=false;
  639.                   settextstyle(defaultfont,horizdir,2);
  640.                   outtextxy(0,0,'Trafiony');
  641.                   delay(750);
  642.                   //cleardevice;
  643.                 end;
  644.               end;
  645. end;
  646.  
  647. procedure rozstaw_statki_komputer(var plansza:array of pole);
  648. var
  649.   statki:array [1..10] of statek;
  650.   i,j,iterator,licznik:word;
  651.   czy_wolne:boolean;//do sprawdzenia czy zmiesci sie statek
  652. begin
  653.   for licznik:=1 to 10 do
  654.   begin
  655.     case licznik of
  656.     1:
  657.     begin
  658.       statki[licznik].dlugosc:=4;
  659.       while true do
  660.       begin
  661.         czy_wolne:=true;
  662.         statki[licznik].orientacja:=random(2)+1;
  663.         if statki[licznik].orientacja=1 then
  664.         begin
  665.           i:=random(10);
  666.           if i+statki[licznik].dlugosc>9 then continue;
  667.           j:=random(10);
  668.           for iterator:=i to i+statki[licznik].dlugosc-1 do
  669.           begin
  670.             if plansza[j+iterator*10].stale<>0 then
  671.             begin
  672.               czy_wolne:=false;
  673.               break;
  674.             end;
  675.           end;
  676.         end
  677.         else
  678.         begin
  679.           j:=random(10);
  680.           if j+statki[licznik].dlugosc>9 then continue;
  681.           i:=random(10);
  682.           for iterator:=j to j+statki[licznik].dlugosc-1 do
  683.           begin
  684.             if plansza[iterator+i*10].stale<>0 then
  685.             begin
  686.               czy_wolne:=false;
  687.               break;
  688.             end;
  689.           end;
  690.         end;
  691.         if czy_wolne then
  692.         begin
  693.           break;
  694.         end;
  695.       end;
  696.       obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  697.       if statki[licznik].orientacja=1 then
  698.       begin
  699.         for iterator:=i to statki[licznik].dlugosc-1+i do
  700.         begin
  701.           plansza[j+iterator*10].stale:=3;
  702.         end;
  703.       end
  704.       else
  705.       begin
  706.         for iterator:=j to statki[licznik].dlugosc-1+j do
  707.         begin
  708.           plansza[iterator+i*10].stale:=3;
  709.         end;
  710.       end;
  711.     end;
  712.     2..3:
  713.     begin
  714.       statki[licznik].dlugosc:=3;
  715.       while true do
  716.       begin
  717.         czy_wolne:=true;
  718.         statki[licznik].orientacja:=random(2)+1;
  719.         if statki[licznik].orientacja=1 then
  720.         begin
  721.           i:=random(10);
  722.           if i+statki[licznik].dlugosc>9 then continue;
  723.           j:=random(10);
  724.           for iterator:=i to i+statki[licznik].dlugosc-1 do
  725.           begin
  726.             if plansza[j+iterator*10].stale<>0 then
  727.             begin
  728.               czy_wolne:=false;
  729.               break;
  730.             end;
  731.           end;
  732.         end
  733.         else
  734.         begin
  735.           j:=random(10);
  736.           if j+statki[licznik].dlugosc>9 then continue;
  737.           i:=random(10);
  738.           for iterator:=j to j+statki[licznik].dlugosc-1 do
  739.           begin
  740.             if plansza[iterator+i*10].stale<>0 then
  741.             begin
  742.               czy_wolne:=false;
  743.               break;
  744.             end;
  745.           end;
  746.         end;
  747.         if czy_wolne then
  748.         begin
  749.           break;
  750.         end;
  751.       end;
  752.       obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  753.       if statki[licznik].orientacja=1 then
  754.       begin
  755.         for iterator:=i to statki[licznik].dlugosc-1+i do
  756.         begin
  757.           plansza[j+iterator*10].stale:=3;
  758.         end;
  759.       end
  760.       else
  761.       begin
  762.         for iterator:=j to statki[licznik].dlugosc-1+j do
  763.         begin
  764.           plansza[iterator+i*10].stale:=3;
  765.         end;
  766.       end;
  767.     end;
  768.     4..6:
  769.     begin
  770.       statki[licznik].dlugosc:=2;
  771.       while true do
  772.       begin
  773.         czy_wolne:=true;
  774.         statki[licznik].orientacja:=random(2)+1;
  775.         if statki[licznik].orientacja=1 then
  776.         begin
  777.           i:=random(10);
  778.           if i+statki[licznik].dlugosc>9 then continue;
  779.           j:=random(10);
  780.           for iterator:=i to i+statki[licznik].dlugosc-1 do
  781.           begin
  782.             if plansza[j+iterator*10].stale<>0 then
  783.             begin
  784.               czy_wolne:=false;
  785.               break;
  786.             end;
  787.           end;
  788.         end
  789.         else
  790.         begin
  791.           j:=random(10);
  792.           if j+statki[licznik].dlugosc>9 then continue;
  793.           i:=random(10);
  794.           for iterator:=j to j+statki[licznik].dlugosc-1 do
  795.           begin
  796.             if plansza[iterator+i*10].stale<>0 then
  797.             begin
  798.               czy_wolne:=false;
  799.               break;
  800.             end;
  801.           end;
  802.         end;
  803.         if czy_wolne then
  804.         begin
  805.           break;
  806.         end;
  807.       end;
  808.       obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  809.       if statki[licznik].orientacja=1 then
  810.       begin
  811.         for iterator:=i to statki[licznik].dlugosc-1+i do
  812.         begin
  813.           plansza[j+iterator*10].stale:=3;
  814.         end;
  815.       end
  816.       else
  817.       begin
  818.         for iterator:=j to statki[licznik].dlugosc-1+j do
  819.         begin
  820.           plansza[iterator+i*10].stale:=3;
  821.         end;
  822.       end;
  823.     end;
  824.     7..10:
  825.     begin
  826.       statki[licznik].dlugosc:=1;
  827.       while true do
  828.       begin
  829.         czy_wolne:=true;
  830.         statki[licznik].orientacja:=random(2)+1;
  831.         i:=random(10);
  832.         j:=random(10);
  833.         if statki[licznik].orientacja=1 then
  834.         begin
  835.           i:=random(10);
  836.           if i+statki[licznik].dlugosc>9 then continue;
  837.           j:=random(10);
  838.           for iterator:=i to i+statki[licznik].dlugosc-1 do
  839.           begin
  840.             if plansza[j+iterator*10].stale<>0 then
  841.             begin
  842.               czy_wolne:=false;
  843.               break;
  844.             end;
  845.           end;
  846.         end
  847.         else
  848.         begin
  849.           j:=random(10);
  850.           if j+statki[licznik].dlugosc>9 then continue;
  851.           i:=random(10);
  852.           for iterator:=j to j+statki[licznik].dlugosc-1 do
  853.           begin
  854.             if plansza[iterator+i*10].stale<>0 then
  855.             begin
  856.               czy_wolne:=false;
  857.               break;
  858.             end;
  859.           end;
  860.         end;
  861.         if czy_wolne then
  862.         begin
  863.           break;
  864.         end;
  865.       end;
  866.       obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  867.       if statki[licznik].orientacja=1 then
  868.       begin
  869.         for iterator:=i to statki[licznik].dlugosc-1+i do
  870.         begin
  871.           plansza[j+iterator*10].stale:=3;
  872.         end;
  873.       end
  874.       else
  875.       begin
  876.         for iterator:=j to statki[licznik].dlugosc-1+j do
  877.         begin
  878.           plansza[iterator+i*10].stale:=3;
  879.         end;
  880.       end;
  881.     end;
  882.     end;
  883.   end;
  884. end;
  885.  
  886. procedure rozstaw_statki_gracz(var plansza:array of pole);
  887. var
  888.   statki:array [1..10] of statek;
  889.   i,j,k,l,licznik,iterator:word;
  890.   klawisz:char;
  891.   czy_enter:boolean;
  892. begin
  893.   for licznik:=1 to 10 do
  894.   begin
  895.     case licznik of
  896.     1:
  897.     begin
  898.       statki[licznik].orientacja:=1;
  899.       statki[licznik].dlugosc:=4;
  900.       i:=0;
  901.       j:=0;
  902.       for iterator:=i to statki[licznik].dlugosc-1 do
  903.       begin
  904.         plansza[iterator*10].tmp:=4;
  905.       end;
  906.       cleardevice;
  907.       rysuj(plansza,0,0);
  908.       while true do
  909.       begin
  910.         if keypressed then
  911.         begin
  912.           klawisz:=readkey;
  913.           czy_enter:=true;
  914.           if statki[licznik].orientacja=1 then
  915.           begin
  916.             for iterator:=i to i+statki[licznik].dlugosc-1 do
  917.             begin
  918.               if plansza[j+iterator*10].stale<>0 then czy_enter:=false;
  919.             end;
  920.           end
  921.           else
  922.           begin
  923.             for iterator:=j to j+statki[licznik].dlugosc-1 do
  924.             begin
  925.               if plansza[iterator+i*10].stale<>0 then czy_enter:=false;
  926.             end;
  927.           end;
  928.           if czy_enter then
  929.           begin
  930.           case klawisz of
  931.           #13:
  932.           begin
  933.             if statki[licznik].orientacja=1 then
  934.             begin
  935.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  936.               for iterator:=i to statki[licznik].dlugosc-1+i do
  937.               begin
  938.                 plansza[j+iterator*10].stale:=3;
  939.               end;
  940.             end
  941.             else
  942.             begin
  943.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  944.               for iterator:=j to statki[licznik].dlugosc-1+j do
  945.               begin
  946.                 plansza[iterator+i*10].stale:=3;
  947.               end;
  948.             end;
  949.             for l:=0 to 9 do
  950.             begin
  951.               for k:=0 to 9 do
  952.               begin
  953.                 plansza[k+l*10].tmp:=0;
  954.               end;
  955.             end;
  956.             break;
  957.           end;
  958.           end;
  959.           end;
  960.           case klawisz of
  961.           #32:
  962.           begin
  963.             if (statki[licznik].orientacja=1)and(j+statki[licznik].dlugosc<11) then
  964.             begin
  965.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  966.               begin
  967.                 plansza[j+iterator*10].tmp:=0;
  968.               end;
  969.               if j+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=2;
  970.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  971.               begin
  972.                 plansza[iterator+i*10].tmp:=4;
  973.               end;
  974.             end
  975.             else if (statki[licznik].orientacja=2)and(i+statki[licznik].dlugosc<11) then
  976.             begin
  977.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  978.               begin
  979.                 plansza[iterator+i*10].tmp:=0;
  980.               end;
  981.               if i+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=1;
  982.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  983.               begin
  984.                 plansza[j+iterator*10].tmp:=4;
  985.               end;
  986.             end;
  987.           end;
  988.           #75:
  989.           begin
  990.             if j>0 then
  991.             begin
  992.               if statki[licznik].orientacja=1 then
  993.               begin
  994.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  995.                 begin
  996.                   plansza[j+iterator*10].tmp:=0;
  997.                 end;
  998.                 dec(j);
  999.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1000.                 begin
  1001.                   plansza[j+iterator*10].tmp:=4;
  1002.                 end;
  1003.               end
  1004.               else
  1005.               begin
  1006.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1007.                 begin
  1008.                   plansza[iterator+i*10].tmp:=0;
  1009.                 end;
  1010.                 dec(j);
  1011.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1012.                 begin
  1013.                   plansza[iterator+i*10].tmp:=4;
  1014.                 end;
  1015.               end;
  1016.             end;
  1017.           end;
  1018.           #77:
  1019.           begin
  1020.             if (statki[licznik].orientacja=1)and(j<9) then
  1021.             begin
  1022.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1023.               begin
  1024.                 plansza[j+iterator*10].tmp:=0;
  1025.               end;
  1026.               inc(j);
  1027.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1028.               begin
  1029.                 plansza[j+iterator*10].tmp:=4;
  1030.               end;
  1031.             end
  1032.             else if (statki[licznik].orientacja=2)and(j+statki[licznik].dlugosc<10)then
  1033.             begin
  1034.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1035.               begin
  1036.                 plansza[iterator+i*10].tmp:=0;
  1037.               end;
  1038.               inc(j);
  1039.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1040.               begin
  1041.                 plansza[iterator+i*10].tmp:=4;
  1042.               end;
  1043.             end;
  1044.           end;
  1045.           #72:
  1046.           begin
  1047.             if i>0 then
  1048.             begin
  1049.               if statki[licznik].orientacja=1 then
  1050.               begin
  1051.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1052.                 begin
  1053.                   plansza[j+iterator*10].tmp:=0;
  1054.                 end;
  1055.                 dec(i);
  1056.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1057.                 begin
  1058.                   plansza[j+iterator*10].tmp:=4;
  1059.                 end;
  1060.               end
  1061.               else
  1062.               begin
  1063.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1064.                 begin
  1065.                   plansza[iterator+i*10].tmp:=0;
  1066.                 end;
  1067.                 dec(i);
  1068.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1069.                 begin
  1070.                   plansza[iterator+i*10].tmp:=4;
  1071.                 end;
  1072.               end;
  1073.             end;
  1074.           end;
  1075.           #80:
  1076.           begin
  1077.             if (statki[licznik].orientacja=1)and(i+statki[licznik].dlugosc<10) then
  1078.             begin
  1079.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1080.               begin
  1081.                 plansza[j+iterator*10].tmp:=0;
  1082.               end;
  1083.               inc(i);
  1084.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1085.               begin
  1086.                 plansza[j+iterator*10].tmp:=4;
  1087.               end;
  1088.             end
  1089.             else if (statki[licznik].orientacja=2)and(i<9)then
  1090.             begin
  1091.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1092.               begin
  1093.                 plansza[iterator+i*10].tmp:=0;
  1094.               end;
  1095.               inc(i);
  1096.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1097.               begin
  1098.                 plansza[iterator+i*10].tmp:=4;
  1099.               end;
  1100.             end;
  1101.           end;
  1102.           end;
  1103.         cleardevice;
  1104.         rysuj(plansza,0,0);
  1105.         end;
  1106.     end;
  1107.     end;
  1108.     2..3:
  1109.     begin
  1110.       statki[licznik].orientacja:=1;
  1111.       statki[licznik].dlugosc:=3;
  1112.       i:=0;
  1113.       j:=0;
  1114.       for iterator:=i to statki[licznik].dlugosc-1 do
  1115.       begin
  1116.         plansza[iterator*10].tmp:=4;
  1117.       end;
  1118.       cleardevice;
  1119.       rysuj(plansza,0,0);
  1120.       while true do
  1121.       begin
  1122.         if keypressed then
  1123.         begin
  1124.           klawisz:=readkey;
  1125.           czy_enter:=true;
  1126.           if statki[licznik].orientacja=1 then
  1127.           begin
  1128.             for iterator:=i to i+statki[licznik].dlugosc-1 do
  1129.             begin
  1130.               if plansza[j+iterator*10].stale<>0 then czy_enter:=false;
  1131.             end;
  1132.           end
  1133.           else
  1134.           begin
  1135.             for iterator:=j to j+statki[licznik].dlugosc-1 do
  1136.             begin
  1137.               if plansza[iterator+i*10].stale<>0 then czy_enter:=false;
  1138.             end;
  1139.           end;
  1140.           if czy_enter then
  1141.           begin
  1142.           case klawisz of
  1143.           #13:
  1144.           begin
  1145.             if statki[licznik].orientacja=1 then
  1146.             begin
  1147.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1148.               for iterator:=i to statki[licznik].dlugosc-1+i do
  1149.               begin
  1150.                 plansza[j+iterator*10].stale:=3;
  1151.               end;
  1152.             end
  1153.             else
  1154.             begin
  1155.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1156.               for iterator:=j to statki[licznik].dlugosc-1+j do
  1157.               begin
  1158.                 plansza[iterator+i*10].stale:=3;
  1159.               end;
  1160.             end;
  1161.             for l:=0 to 9 do
  1162.             begin
  1163.               for k:=0 to 9 do
  1164.               begin
  1165.                 plansza[k+l*10].tmp:=0;
  1166.               end;
  1167.             end;
  1168.             break;
  1169.           end;
  1170.           end;
  1171.           end;
  1172.           case klawisz of
  1173.           #32:
  1174.           begin
  1175.             if (statki[licznik].orientacja=1)and(j+statki[licznik].dlugosc<11) then
  1176.             begin
  1177.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1178.               begin
  1179.                 plansza[j+iterator*10].tmp:=0;
  1180.               end;
  1181.               if j+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=2;
  1182.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1183.               begin
  1184.                 plansza[iterator+i*10].tmp:=4;
  1185.               end;
  1186.             end
  1187.             else if (statki[licznik].orientacja=2)and(i+statki[licznik].dlugosc<11) then
  1188.             begin
  1189.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1190.               begin
  1191.                 plansza[iterator+i*10].tmp:=0;
  1192.               end;
  1193.               if i+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=1;
  1194.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1195.               begin
  1196.                 plansza[j+iterator*10].tmp:=4;
  1197.               end;
  1198.             end;
  1199.           end;
  1200.           #75:
  1201.           begin
  1202.             if j>0 then
  1203.             begin
  1204.               if statki[licznik].orientacja=1 then
  1205.               begin
  1206.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1207.                 begin
  1208.                   plansza[j+iterator*10].tmp:=0;
  1209.                 end;
  1210.                 dec(j);
  1211.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1212.                 begin
  1213.                   plansza[j+iterator*10].tmp:=4;
  1214.                 end;
  1215.               end
  1216.               else
  1217.               begin
  1218.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1219.                 begin
  1220.                   plansza[iterator+i*10].tmp:=0;
  1221.                 end;
  1222.                 dec(j);
  1223.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1224.                 begin
  1225.                   plansza[iterator+i*10].tmp:=4;
  1226.                 end;
  1227.               end;
  1228.             end;
  1229.           end;
  1230.           #77:
  1231.           begin
  1232.             if (statki[licznik].orientacja=1)and(j<9) then
  1233.             begin
  1234.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1235.               begin
  1236.                 plansza[j+iterator*10].tmp:=0;
  1237.               end;
  1238.               inc(j);
  1239.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1240.               begin
  1241.                 plansza[j+iterator*10].tmp:=4;
  1242.               end;
  1243.             end
  1244.             else if (statki[licznik].orientacja=2)and(j+statki[licznik].dlugosc<10)then
  1245.             begin
  1246.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1247.               begin
  1248.                 plansza[iterator+i*10].tmp:=0;
  1249.               end;
  1250.               inc(j);
  1251.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1252.               begin
  1253.                 plansza[iterator+i*10].tmp:=4;
  1254.               end;
  1255.             end;
  1256.           end;
  1257.           #72:
  1258.           begin
  1259.             if i>0 then
  1260.             begin
  1261.               if statki[licznik].orientacja=1 then
  1262.               begin
  1263.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1264.                 begin
  1265.                   plansza[j+iterator*10].tmp:=0;
  1266.                 end;
  1267.                 dec(i);
  1268.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1269.                 begin
  1270.                   plansza[j+iterator*10].tmp:=4;
  1271.                 end;
  1272.               end
  1273.               else
  1274.               begin
  1275.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1276.                 begin
  1277.                   plansza[iterator+i*10].tmp:=0;
  1278.                 end;
  1279.                 dec(i);
  1280.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1281.                 begin
  1282.                   plansza[iterator+i*10].tmp:=4;
  1283.                 end;
  1284.               end;
  1285.             end;
  1286.           end;
  1287.           #80:
  1288.           begin
  1289.             if (statki[licznik].orientacja=1)and(i+statki[licznik].dlugosc<10) then
  1290.             begin
  1291.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1292.               begin
  1293.                 plansza[j+iterator*10].tmp:=0;
  1294.               end;
  1295.               inc(i);
  1296.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1297.               begin
  1298.                 plansza[j+iterator*10].tmp:=4;
  1299.               end;
  1300.             end
  1301.             else if (statki[licznik].orientacja=2)and(i<9)then
  1302.             begin
  1303.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1304.               begin
  1305.                 plansza[iterator+i*10].tmp:=0;
  1306.               end;
  1307.               inc(i);
  1308.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1309.               begin
  1310.                 plansza[iterator+i*10].tmp:=4;
  1311.               end;
  1312.             end;
  1313.           end;
  1314.           end;
  1315.         cleardevice;
  1316.         rysuj(plansza,0,0);
  1317.         end;
  1318.     end;
  1319.     end;
  1320.     4..6:
  1321.     begin
  1322.       statki[licznik].orientacja:=1;
  1323.       statki[licznik].dlugosc:=2;
  1324.       i:=0;
  1325.       j:=0;
  1326.       for iterator:=i to statki[licznik].dlugosc-1 do
  1327.       begin
  1328.         plansza[iterator*10].tmp:=4;
  1329.       end;
  1330.       cleardevice;
  1331.       rysuj(plansza,0,0);
  1332.       while true do
  1333.       begin
  1334.         if keypressed then
  1335.         begin
  1336.           klawisz:=readkey;
  1337.           czy_enter:=true;
  1338.           if statki[licznik].orientacja=1 then
  1339.           begin
  1340.             for iterator:=i to i+statki[licznik].dlugosc-1 do
  1341.             begin
  1342.               if plansza[j+iterator*10].stale<>0 then czy_enter:=false;
  1343.             end;
  1344.           end
  1345.           else
  1346.           begin
  1347.             for iterator:=j to j+statki[licznik].dlugosc-1 do
  1348.             begin
  1349.               if plansza[iterator+i*10].stale<>0 then czy_enter:=false;
  1350.             end;
  1351.           end;
  1352.           if czy_enter then
  1353.           begin
  1354.           case klawisz of
  1355.           #13:
  1356.           begin
  1357.             if statki[licznik].orientacja=1 then
  1358.             begin
  1359.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1360.               for iterator:=i to statki[licznik].dlugosc-1+i do
  1361.               begin
  1362.                 plansza[j+iterator*10].stale:=3;
  1363.               end;
  1364.             end
  1365.             else
  1366.             begin
  1367.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1368.               for iterator:=j to statki[licznik].dlugosc-1+j do
  1369.               begin
  1370.                 plansza[iterator+i*10].stale:=3;
  1371.               end;
  1372.             end;
  1373.             for l:=0 to 9 do
  1374.             begin
  1375.               for k:=0 to 9 do
  1376.               begin
  1377.                 plansza[k+l*10].tmp:=0;
  1378.               end;
  1379.             end;
  1380.             break;
  1381.           end;
  1382.           end;
  1383.           end;
  1384.           case klawisz of
  1385.           #32:
  1386.           begin
  1387.             if (statki[licznik].orientacja=1)and(j+statki[licznik].dlugosc<11) then
  1388.             begin
  1389.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1390.               begin
  1391.                 plansza[j+iterator*10].tmp:=0;
  1392.               end;
  1393.               if j+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=2;
  1394.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1395.               begin
  1396.                 plansza[iterator+i*10].tmp:=4;
  1397.               end;
  1398.             end
  1399.             else if (statki[licznik].orientacja=2)and(i+statki[licznik].dlugosc<11) then
  1400.             begin
  1401.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1402.               begin
  1403.                 plansza[iterator+i*10].tmp:=0;
  1404.               end;
  1405.               if i+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=1;
  1406.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1407.               begin
  1408.                 plansza[j+iterator*10].tmp:=4;
  1409.               end;
  1410.             end;
  1411.           end;
  1412.           #75:
  1413.           begin
  1414.             if j>0 then
  1415.             begin
  1416.               if statki[licznik].orientacja=1 then
  1417.               begin
  1418.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1419.                 begin
  1420.                   plansza[j+iterator*10].tmp:=0;
  1421.                 end;
  1422.                 dec(j);
  1423.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1424.                 begin
  1425.                   plansza[j+iterator*10].tmp:=4;
  1426.                 end;
  1427.               end
  1428.               else
  1429.               begin
  1430.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1431.                 begin
  1432.                   plansza[iterator+i*10].tmp:=0;
  1433.                 end;
  1434.                 dec(j);
  1435.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1436.                 begin
  1437.                   plansza[iterator+i*10].tmp:=4;
  1438.                 end;
  1439.               end;
  1440.             end;
  1441.           end;
  1442.           #77:
  1443.           begin
  1444.             if (statki[licznik].orientacja=1)and(j<9) then
  1445.             begin
  1446.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1447.               begin
  1448.                 plansza[j+iterator*10].tmp:=0;
  1449.               end;
  1450.               inc(j);
  1451.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1452.               begin
  1453.                 plansza[j+iterator*10].tmp:=4;
  1454.               end;
  1455.             end
  1456.             else if (statki[licznik].orientacja=2)and(j+statki[licznik].dlugosc<10)then
  1457.             begin
  1458.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1459.               begin
  1460.                 plansza[iterator+i*10].tmp:=0;
  1461.               end;
  1462.               inc(j);
  1463.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1464.               begin
  1465.                 plansza[iterator+i*10].tmp:=4;
  1466.               end;
  1467.             end;
  1468.           end;
  1469.           #72:
  1470.           begin
  1471.             if i>0 then
  1472.             begin
  1473.               if statki[licznik].orientacja=1 then
  1474.               begin
  1475.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1476.                 begin
  1477.                   plansza[j+iterator*10].tmp:=0;
  1478.                 end;
  1479.                 dec(i);
  1480.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1481.                 begin
  1482.                   plansza[j+iterator*10].tmp:=4;
  1483.                 end;
  1484.               end
  1485.               else
  1486.               begin
  1487.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1488.                 begin
  1489.                   plansza[iterator+i*10].tmp:=0;
  1490.                 end;
  1491.                 dec(i);
  1492.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1493.                 begin
  1494.                   plansza[iterator+i*10].tmp:=4;
  1495.                 end;
  1496.               end;
  1497.             end;
  1498.           end;
  1499.           #80:
  1500.           begin
  1501.             if (statki[licznik].orientacja=1)and(i+statki[licznik].dlugosc<10) then
  1502.             begin
  1503.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1504.               begin
  1505.                 plansza[j+iterator*10].tmp:=0;
  1506.               end;
  1507.               inc(i);
  1508.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1509.               begin
  1510.                 plansza[j+iterator*10].tmp:=4;
  1511.               end;
  1512.             end
  1513.             else if (statki[licznik].orientacja=2)and(i<9)then
  1514.             begin
  1515.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1516.               begin
  1517.                 plansza[iterator+i*10].tmp:=0;
  1518.               end;
  1519.               inc(i);
  1520.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1521.               begin
  1522.                 plansza[iterator+i*10].tmp:=4;
  1523.               end;
  1524.             end;
  1525.           end;
  1526.           end;
  1527.         cleardevice;
  1528.         rysuj(plansza,0,0);
  1529.         end;
  1530.     end;
  1531.     end;
  1532.     7..10:
  1533.     begin
  1534.       statki[licznik].orientacja:=1;
  1535.       statki[licznik].dlugosc:=1;
  1536.       i:=0;
  1537.       j:=0;
  1538.       for iterator:=i to statki[licznik].dlugosc-1 do
  1539.       begin
  1540.         plansza[iterator*10].tmp:=4;
  1541.       end;
  1542.       cleardevice;
  1543.       rysuj(plansza,0,0);
  1544.       while true do
  1545.       begin
  1546.         if keypressed then
  1547.         begin
  1548.           klawisz:=readkey;
  1549.           czy_enter:=true;
  1550.           if statki[licznik].orientacja=1 then
  1551.           begin
  1552.             for iterator:=i to i+statki[licznik].dlugosc-1 do
  1553.             begin
  1554.               if plansza[j+iterator*10].stale<>0 then czy_enter:=false;
  1555.             end;
  1556.           end
  1557.           else
  1558.           begin
  1559.             for iterator:=j to j+statki[licznik].dlugosc-1 do
  1560.             begin
  1561.               if plansza[iterator+i*10].stale<>0 then czy_enter:=false;
  1562.             end;
  1563.           end;
  1564.           if czy_enter then
  1565.           begin
  1566.           case klawisz of
  1567.           #13:
  1568.           begin
  1569.             if statki[licznik].orientacja=1 then
  1570.             begin
  1571.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1572.               for iterator:=i to statki[licznik].dlugosc-1+i do
  1573.               begin
  1574.                 plansza[j+iterator*10].stale:=3;
  1575.               end;
  1576.             end
  1577.             else
  1578.             begin
  1579.               obrysowanie(plansza,statki[licznik].orientacja,statki[licznik].dlugosc,i,j);
  1580.               for iterator:=j to statki[licznik].dlugosc-1+j do
  1581.               begin
  1582.                 plansza[iterator+i*10].stale:=3;
  1583.               end;
  1584.             end;
  1585.             for l:=0 to 9 do
  1586.             begin
  1587.               for k:=0 to 9 do
  1588.               begin
  1589.                 plansza[k+l*10].tmp:=0;
  1590.               end;
  1591.             end;
  1592.             break;
  1593.           end;
  1594.           end;
  1595.           end;
  1596.           case klawisz of
  1597.           #32:
  1598.           begin
  1599.             if (statki[licznik].orientacja=1)and(j+statki[licznik].dlugosc<11) then
  1600.             begin
  1601.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1602.               begin
  1603.                 plansza[j+iterator*10].tmp:=0;
  1604.               end;
  1605.               if j+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=2;
  1606.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1607.               begin
  1608.                 plansza[iterator+i*10].tmp:=4;
  1609.               end;
  1610.             end
  1611.             else if (statki[licznik].orientacja=2)and(i+statki[licznik].dlugosc<11) then
  1612.             begin
  1613.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1614.               begin
  1615.                 plansza[iterator+i*10].tmp:=0;
  1616.               end;
  1617.               if i+statki[licznik].dlugosc<11 then statki[licznik].orientacja:=1;
  1618.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1619.               begin
  1620.                 plansza[j+iterator*10].tmp:=4;
  1621.               end;
  1622.             end;
  1623.           end;
  1624.           #75:
  1625.           begin
  1626.             if j>0 then
  1627.             begin
  1628.               if statki[licznik].orientacja=1 then
  1629.               begin
  1630.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1631.                 begin
  1632.                   plansza[j+iterator*10].tmp:=0;
  1633.                 end;
  1634.                 dec(j);
  1635.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1636.                 begin
  1637.                   plansza[j+iterator*10].tmp:=4;
  1638.                 end;
  1639.               end
  1640.               else
  1641.               begin
  1642.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1643.                 begin
  1644.                   plansza[iterator+i*10].tmp:=0;
  1645.                 end;
  1646.                 dec(j);
  1647.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1648.                 begin
  1649.                   plansza[iterator+i*10].tmp:=4;
  1650.                 end;
  1651.               end;
  1652.             end;
  1653.           end;
  1654.           #77:
  1655.           begin
  1656.             if (statki[licznik].orientacja=1)and(j<9) then
  1657.             begin
  1658.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1659.               begin
  1660.                 plansza[j+iterator*10].tmp:=0;
  1661.               end;
  1662.               inc(j);
  1663.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1664.               begin
  1665.                 plansza[j+iterator*10].tmp:=4;
  1666.               end;
  1667.             end
  1668.             else if (statki[licznik].orientacja=2)and(j+statki[licznik].dlugosc<10)then
  1669.             begin
  1670.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1671.               begin
  1672.                 plansza[iterator+i*10].tmp:=0;
  1673.               end;
  1674.               inc(j);
  1675.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1676.               begin
  1677.                 plansza[iterator+i*10].tmp:=4;
  1678.               end;
  1679.             end;
  1680.           end;
  1681.           #72:
  1682.           begin
  1683.             if i>0 then
  1684.             begin
  1685.               if statki[licznik].orientacja=1 then
  1686.               begin
  1687.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1688.                 begin
  1689.                   plansza[j+iterator*10].tmp:=0;
  1690.                 end;
  1691.                 dec(i);
  1692.                 for iterator:=i to i+statki[licznik].dlugosc-1 do
  1693.                 begin
  1694.                   plansza[j+iterator*10].tmp:=4;
  1695.                 end;
  1696.               end
  1697.               else
  1698.               begin
  1699.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1700.                 begin
  1701.                   plansza[iterator+i*10].tmp:=0;
  1702.                 end;
  1703.                 dec(i);
  1704.                 for iterator:=j to j+statki[licznik].dlugosc-1 do
  1705.                 begin
  1706.                   plansza[iterator+i*10].tmp:=4;
  1707.                 end;
  1708.               end;
  1709.             end;
  1710.           end;
  1711.           #80:
  1712.           begin
  1713.             if (statki[licznik].orientacja=1)and(i+statki[licznik].dlugosc<10) then
  1714.             begin
  1715.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1716.               begin
  1717.                 plansza[j+iterator*10].tmp:=0;
  1718.               end;
  1719.               inc(i);
  1720.               for iterator:=i to i+statki[licznik].dlugosc-1 do
  1721.               begin
  1722.                 plansza[j+iterator*10].tmp:=4;
  1723.               end;
  1724.             end
  1725.             else if (statki[licznik].orientacja=2)and(i<9)then
  1726.             begin
  1727.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1728.               begin
  1729.                 plansza[iterator+i*10].tmp:=0;
  1730.               end;
  1731.               inc(i);
  1732.               for iterator:=j to j+statki[licznik].dlugosc-1 do
  1733.               begin
  1734.                 plansza[iterator+i*10].tmp:=4;
  1735.               end;
  1736.             end;
  1737.           end;
  1738.           end;
  1739.         cleardevice;
  1740.         rysuj(plansza,0,0);
  1741.         end;
  1742.     end;
  1743.     end;
  1744.     end;
  1745.   end;
  1746.   for i:=0 to 9 do
  1747.   begin
  1748.     for j:=0 to 9 do
  1749.     begin
  1750.       if plansza[j+10*i].stale=2 then plansza[j+10*i].stale:=0;
  1751.       if plansza[j+10*i].stale=3 then plansza[j+10*i].stale:=1;
  1752.     end;
  1753.   end;
  1754. end;
  1755.  
  1756. procedure intro;
  1757. var
  1758.   powitanie:string;
  1759. begin
  1760.   setcolor(red);
  1761.   settextstyle(0,0,3);
  1762.   powitanie:='Witaj w grze Statki!';
  1763.   outtextxy(100,getmaxy div 2 - 40,powitanie);
  1764.   delay(2000);
  1765.   cleardevice;
  1766. end;
  1767.  
  1768. function koniec:boolean;
  1769. var
  1770.   klawisz:char;
  1771.   licznik:word;
  1772. begin
  1773.   licznik:=1;
  1774.   while true do
  1775.   begin
  1776.     if keypressed then
  1777.     begin
  1778.       klawisz:=readkey;
  1779.       case klawisz of
  1780.       #80:if licznik<2 then inc(licznik);
  1781.       #72:if licznik>1 then dec(licznik);
  1782.       #13:
  1783.       begin
  1784.         case licznik of
  1785.         1:
  1786.         begin
  1787.           koniec:=true;
  1788.           exit;
  1789.         end;
  1790.         2:
  1791.         begin
  1792.           koniec:=false;
  1793.           cleardevice;
  1794.           exit;
  1795.         end;
  1796.         end;
  1797.       end;
  1798.       end;
  1799.     end;
  1800.     setcolor(white);
  1801.     outtextxy((getmaxx-textwidth('WYJSC?'))div 2,getmaxy div 2 - 2*textheight('TAK'),'WYJSC?');
  1802.     case licznik of
  1803.     1:
  1804.     begin
  1805.       setcolor(red);
  1806.       outtextxy((getmaxx-textwidth('TAK'))div 2,getmaxy div 2,'TAK');
  1807.       setcolor(white);
  1808.       outtextxy((getmaxx-textwidth('NIE'))div 2,getmaxy div 2 + 2*textheight('TAK'),'NIE');
  1809.     end;
  1810.     2:
  1811.     begin
  1812.       setcolor(white);
  1813.       outtextxy((getmaxx-textwidth('TAK'))div 2,getmaxy div 2,'TAK');
  1814.       setcolor(red);
  1815.       outtextxy((getmaxx-textwidth('NIE'))div 2,getmaxy div 2 + 2*textheight('TAK'),'NIE');
  1816.     end;
  1817.     end;
  1818.   end;
  1819. end;
  1820.  
  1821. procedure pvp;
  1822. var
  1823.   plansza_gracz1:array [0..99] of pole;
  1824.   plansza_gracz2:array [0..99] of pole;
  1825.   licznik,i,j,k,l:word;
  1826.   klawisz:char;
  1827.   czy_wygral:boolean;//do sprawdzenia, ktory gracz wygral
  1828. begin
  1829.   settextstyle(0,0,3);
  1830.   repeat
  1831.     outtextxy((getmaxx-textwidth('GRACZ I ROZSTAWIA STATKI')) div 2,getmaxy div 2,'GRACZ I ROZSTAWIA STATKI');
  1832.   until keypressed;
  1833.   for i:=0 to 9 do
  1834.   begin
  1835.     for j:=0 to 9 do
  1836.     begin
  1837.       plansza_gracz1[j+i*10].stale:=0;
  1838.       plansza_gracz1[j+i*10].tmp:=0;
  1839.     end;
  1840.   end;
  1841.   klawisz:=readkey;
  1842.   rozstaw_statki_gracz(plansza_gracz1);
  1843.   cleardevice;
  1844.   settextstyle(0,0,3);
  1845.   repeat
  1846.     outtextxy((getmaxx-textwidth('GRACZ II ROZSTAWIA STATKI')) div 2,getmaxy div 2,'GRACZ II ROZSTAWIA STATKI');
  1847.   until keypressed;
  1848.   for i:=0 to 9 do
  1849.   begin
  1850.     for j:=0 to 9 do
  1851.     begin
  1852.       plansza_gracz2[j+i*10].stale:=0;
  1853.       plansza_gracz2[j+i*10].tmp:=0;
  1854.     end;
  1855.   end;
  1856.   klawisz:=readkey;
  1857.   rozstaw_statki_gracz(plansza_gracz2);
  1858.   cleardevice;
  1859.   settextstyle(0,0,3);
  1860.   outtextxy((getmaxx-textwidth('ROZPOCZYNA GRACZ NR 1')) div 2,getmaxy div 2,'ROZPOCZYNA GRACZ NR 1');
  1861.   repeat until keypressed;
  1862.   klawisz:=readkey;
  1863.   licznik:=1;
  1864.   while true do
  1865.   begin
  1866.     if licznik mod 2 <> 0 then
  1867.     begin
  1868.       i:=0;
  1869.       j:=0;
  1870.       cleardevice;
  1871.       plansza_gracz2[0].tmp:=4;
  1872.       settextstyle(defaultfont,horizdir,2);
  1873.       outtext('GRACZ I');
  1874.       rysuj(plansza_gracz2,0,0);
  1875.       plansza_gracz2[0].tmp:=0;
  1876.       while true do
  1877.       begin
  1878.         if keypressed then
  1879.         begin
  1880.           klawisz:=readkey;
  1881.           case klawisz of
  1882.           #75:if j>0 then dec(j);            //strzalka w lewo
  1883.           #77:if j<9 then inc(j);            //strzalka w prawo
  1884.           #72:if i>0 then dec(i);            //strzalka w gore
  1885.           #80:if i<9 then inc(i);            //strzalka w dol
  1886.           #112:
  1887.           begin
  1888.             cleardevice;
  1889.             for k:=0 to 9 do
  1890.             begin
  1891.               for l:=0 to 9 do
  1892.               begin
  1893.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=4;
  1894.               end;
  1895.             end;
  1896.             rysuj(plansza_gracz1,0,0);
  1897.             for k:=0 to 9 do
  1898.             begin
  1899.               for l:=0 to 9 do
  1900.               begin
  1901.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=0;
  1902.               end;
  1903.             end;
  1904.             settextstyle(defaultfont,horizdir,2);
  1905.             outtext('GRACZ I');
  1906.             moveto(15,12*30);
  1907.             settextstyle(defaultfont,horizdir,1);
  1908.             outtext('Nacisinij dowolny klawisz, zeby powrocic...');
  1909.             repeat until keypressed;
  1910.             klawisz:=readkey;
  1911.           end;
  1912.           #13:
  1913.           begin
  1914.             case plansza_gracz2[j+i*10].stale of
  1915.               0:
  1916.               begin
  1917.                 plansza_gracz2[j+i*10].stale:=2;
  1918.                 cleardevice;
  1919.                 settextstyle(defaultfont,horizdir,2);
  1920.                 outtext('GRACZ I');
  1921.                 rysuj(plansza_gracz2,0,0);
  1922.                 moveto(15,12*30);
  1923.                 settextstyle(defaultfont,horizdir,1);
  1924.                 outtext('Nacisnij dowolny klawisz...');
  1925.                 repeat until keypressed;
  1926.                 klawisz:=readkey;
  1927.                 break;
  1928.               end;
  1929.               1:
  1930.               begin
  1931.                 cleardevice;
  1932.                 plansza_gracz2[j+i*10].stale:=3;
  1933.                 rysuj(plansza_gracz2,0,0);
  1934.                 czy_zatopiony(plansza_gracz2,i,j);
  1935.                 czy_wygral:=true;
  1936.                 for k:=0 to 9 do
  1937.                 begin
  1938.                   for l:=0 to 9 do
  1939.                   begin
  1940.                     if plansza_gracz2[l+k*10].stale=1 then
  1941.                     begin
  1942.                       czy_wygral:=false;
  1943.                       break;
  1944.                     end;
  1945.                   end;
  1946.                 end;
  1947.                 if czy_wygral then
  1948.                 begin
  1949.                   cleardevice;
  1950.                   settextstyle(defaultfont,horizdir,2);
  1951.                   outtextxy((getmaxx-textwidth('WYGRAL GRACZ NR 1')) div 2,getmaxy div 2,'WYGRAL GRACZ NR 1');
  1952.                   settextstyle(defaultfont,horizdir,1);
  1953.                   outtextxy((getmaxx-textwidth('Nacisnij dowolny klawisz, zeby kontynuowac...')) div 2,getmaxy div 2 + 4*textheight('WYGRAL GRACZ NR 1'),'Nacisnij dowolny klawisz, zeby kontynuowac...');
  1954.                   repeat until keypressed;
  1955.                   klawisz:=readkey;
  1956.                   cleardevice;
  1957.                   settextstyle(0,0,3);
  1958.                   exit;
  1959.                 end;
  1960.               end;
  1961.             end;
  1962.           end;
  1963.           end;
  1964.           plansza_gracz2[j+10*i].tmp:=4;
  1965.           cleardevice;
  1966.           settextstyle(defaultfont,horizdir,2);
  1967.           outtext('GRACZ I');
  1968.           rysuj(plansza_gracz2,0,0);
  1969.           moveto(15,12*30);
  1970.           settextstyle(defaultfont,horizdir,1);
  1971.           outtext('Nacisnsij p by podejrzec swoja plansze.');
  1972.           plansza_gracz2[j+10*i].tmp:=0;
  1973.         end;
  1974.       end;
  1975.     end
  1976.     else
  1977.     begin
  1978.       i:=0;
  1979.       j:=0;
  1980.       cleardevice;
  1981.       plansza_gracz1[0].tmp:=4;
  1982.       settextstyle(defaultfont,horizdir,2);
  1983.       outtext('GRACZ II');
  1984.       rysuj(plansza_gracz1,0,0);
  1985.       plansza_gracz1[0].tmp:=0;
  1986.       while true do
  1987.       begin
  1988.         if keypressed then
  1989.         begin
  1990.           klawisz:=readkey;
  1991.           case klawisz of
  1992.           #75:if j>0 then dec(j);            //strzalka w lewo
  1993.           #77:if j<9 then inc(j);            //strzalka w prawo
  1994.           #72:if i>0 then dec(i);            //strzalka w gore
  1995.           #80:if i<9 then inc(i);            //strzalka w dol
  1996.           #112:
  1997.           begin
  1998.             cleardevice;
  1999.             settextstyle(defaultfont,horizdir,2);
  2000.             outtext('GRACZ II');
  2001.             for k:=0 to 9 do
  2002.             begin
  2003.               for l:=0 to 9 do
  2004.               begin
  2005.                 if plansza_gracz2[l+k*10].stale=1 then plansza_gracz2[l+k*10].tmp:=4;
  2006.               end;
  2007.             end;
  2008.             rysuj(plansza_gracz2,0,0);
  2009.             for k:=0 to 9 do
  2010.             begin
  2011.               for l:=0 to 9 do
  2012.               begin
  2013.                 if plansza_gracz2[l+k*10].stale=1 then plansza_gracz2[l+k*10].tmp:=0;
  2014.               end;
  2015.             end;
  2016.             moveto(15,12*30);
  2017.             settextstyle(defaultfont,horizdir,1);
  2018.             outtext('Nacisinij dowolny klawisz, zeby powrocic...');
  2019.             repeat until keypressed;
  2020.             klawisz:=readkey;
  2021.           end;
  2022.           #13:
  2023.           begin
  2024.             case plansza_gracz1[j+i*10].stale of
  2025.               0:
  2026.               begin
  2027.                 plansza_gracz1[j+i*10].stale:=2;
  2028.                 cleardevice;
  2029.                 settextstyle(defaultfont,horizdir,2);
  2030.                 outtext('GRACZ II');
  2031.                 rysuj(plansza_gracz1,0,0);
  2032.                 moveto(15,12*30);
  2033.                 settextstyle(defaultfont,horizdir,1);
  2034.                 outtext('Nacisnij dowolny klawisz...');
  2035.                 repeat until keypressed;
  2036.                 klawisz:=readkey;
  2037.                 break;
  2038.               end;
  2039.               1:
  2040.               begin
  2041.                 cleardevice;
  2042.                 plansza_gracz1[j+i*10].stale:=3;
  2043.                 rysuj(plansza_gracz1,0,0);
  2044.                 czy_zatopiony(plansza_gracz1,i,j);
  2045.                 czy_wygral:=true;
  2046.                 for k:=0 to 9 do
  2047.                 begin
  2048.                   for l:=0 to 9 do
  2049.                   begin
  2050.                     if plansza_gracz2[l+k*10].stale=1 then
  2051.                     begin
  2052.                       czy_wygral:=false;
  2053.                       break;
  2054.                     end;
  2055.                   end;
  2056.                 end;
  2057.                 if czy_wygral then
  2058.                 begin
  2059.                   cleardevice;
  2060.                   settextstyle(defaultfont,horizdir,2);
  2061.                   outtextxy((getmaxx-textwidth('WYGRAL GRACZ NR 2')) div 2,getmaxy div 2,'WYGRAL GRACZ NR 2');
  2062.                   settextstyle(defaultfont,horizdir,1);
  2063.                   outtextxy((getmaxx-textwidth('Nacisnij dowolny klawisz, zeby kontynuowac...')) div 2,getmaxy div 2 + 4*textheight('WYGRAL GRACZ NR 2'),'Nacisnij dowolny klawisz, zeby kontynuowac...');
  2064.                   repeat until keypressed;
  2065.                   klawisz:=readkey;
  2066.                   cleardevice;
  2067.                   settextstyle(0,0,3);
  2068.                   exit;
  2069.                 end;
  2070.               end;
  2071.             end;
  2072.           end;
  2073.           end;
  2074.           plansza_gracz1[j+10*i].tmp:=4;
  2075.           cleardevice;
  2076.           settextstyle(defaultfont,horizdir,2);
  2077.           outtext('GRACZ II');
  2078.           rysuj(plansza_gracz1,0,0);
  2079.           moveto(15,12*30);
  2080.           settextstyle(defaultfont,horizdir,1);
  2081.           outtext('Nacisnsij p by podejrzec swoja plansze.');
  2082.           plansza_gracz1[j+10*i].tmp:=0;
  2083.         end;
  2084.       end;
  2085.     end;
  2086.     inc(licznik);
  2087.   end;
  2088.  
  2089.   delay(3000);
  2090.   cleardevice;
  2091.  
  2092. end;
  2093.  
  2094. procedure pve;
  2095. var
  2096.   plansza_gracz1:array [0..99] of pole;
  2097.   plansza_komputer:array [0..99] of pole;
  2098.   zapamietane_i,zapamietane_j,orientacja,i,j,k,l,iterator:word;
  2099.   licznik:integer;
  2100.   klawisz:char;
  2101.   czy_wygral,statek_napoczety,przerwanie:boolean;
  2102. begin
  2103.   statek_napoczety:=false;
  2104.   randomize;
  2105.   for i:=0 to 9 do
  2106.   begin
  2107.     for j:=0 to 9 do
  2108.     begin
  2109.       plansza_gracz1[j+i*10].stale:=0;
  2110.       plansza_gracz1[j+i*10].tmp:=0;
  2111.     end;
  2112.   end;
  2113.   rozstaw_statki_gracz(plansza_gracz1);
  2114.   cleardevice;
  2115.   rysuj(plansza_gracz1,0,0);
  2116.   for i:=0 to 9 do
  2117.   begin
  2118.     for j:=0 to 9 do
  2119.     begin
  2120.       plansza_komputer[j+i*10].stale:=0;
  2121.       plansza_komputer[j+i*10].tmp:=0;
  2122.     end;
  2123.   end;
  2124.   rozstaw_statki_komputer(plansza_komputer);
  2125.   cleardevice;
  2126.   for i:=0 to 9 do
  2127.   begin
  2128.     for j:=0 to 9 do
  2129.     begin
  2130.       if plansza_komputer[j+i*10].stale=3 then plansza_komputer[j+i*10].stale:=1;
  2131.       if plansza_komputer[j+i*10].stale=2 then plansza_komputer[j+i*10].stale:=0;
  2132.       if plansza_gracz1[j+i*10].stale=3 then plansza_gracz1[j+i*10].stale:=1;
  2133.       if plansza_gracz1[j+i*10].stale=2 then plansza_gracz1[j+i*10].stale:=0;
  2134.     end;
  2135.   end;
  2136.   licznik:=1;
  2137.   while true do
  2138.   begin
  2139.     if licznik mod 2 <> 0 then
  2140.     begin
  2141.       i:=0;
  2142.       j:=0;
  2143.       plansza_komputer[0].tmp:=4;
  2144.       rysuj(plansza_komputer,0,0);
  2145.       plansza_komputer[0].tmp:=0;
  2146.  
  2147.       for k:=0 to 9 do
  2148.       begin
  2149.         for l:=0 to 9 do
  2150.         begin
  2151.           if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=4;
  2152.         end;
  2153.       end;
  2154.       rysuj(plansza_gracz1,12*szerokosc,0);
  2155.       for k:=0 to 9 do
  2156.       begin
  2157.         for l:=0 to 9 do
  2158.         begin
  2159.           if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=0;
  2160.         end;
  2161.       end;
  2162.       while true do
  2163.       begin
  2164.         if keypressed then
  2165.         begin
  2166.           klawisz:=readkey;
  2167.           case klawisz of
  2168.           #75:if j>0 then dec(j);            //strzalka w lewo
  2169.           #77:if j<9 then inc(j);            //strzalka w prawo
  2170.           #72:if i>0 then dec(i);            //strzalka w gore
  2171.           #80:if i<9 then inc(i);            //strzalka w dol
  2172.           #112:
  2173.           begin
  2174.             cleardevice;
  2175.             for k:=0 to 9 do
  2176.             begin
  2177.               for l:=0 to 9 do
  2178.               begin
  2179.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=4;
  2180.               end;
  2181.             end;
  2182.             rysuj(plansza_gracz1,0,0);
  2183.             for k:=0 to 9 do
  2184.             begin
  2185.               for l:=0 to 9 do
  2186.               begin
  2187.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=0;
  2188.               end;
  2189.             end;
  2190.             {for k:=0 to 9 do
  2191.             begin
  2192.               for l:=0 to 9 do
  2193.               begin
  2194.                 if plansza_komputer[l+k*10].stale=1 then plansza_komputer[l+k*10].tmp:=4;
  2195.               end;
  2196.             end;
  2197.             rysuj(plansza_komputer);
  2198.             for k:=0 to 9 do
  2199.             begin
  2200.               for l:=0 to 9 do
  2201.               begin
  2202.                 if plansza_komputer[l+k*10].stale=1 then plansza_komputer[l+k*10].tmp:=0;
  2203.               end;
  2204.             end;}
  2205.             moveto(15,12*30);
  2206.             settextstyle(defaultfont,horizdir,1);
  2207.             outtext('Nacisinij dowolny klawisz, zeby powrocic...');
  2208.             repeat until keypressed;
  2209.           end;
  2210.           #13:
  2211.           begin
  2212.             case plansza_komputer[j+i*10].stale of
  2213.             0:
  2214.             begin
  2215.               plansza_komputer[j+i*10].stale:=2;
  2216.               break;
  2217.             end;
  2218.             1:
  2219.             begin
  2220.               plansza_komputer[j+i*10].stale:=3;
  2221.               czy_zatopiony(plansza_komputer,i,j);
  2222.               czy_wygral:=true;
  2223.               for k:=0 to 9 do
  2224.               begin
  2225.                 for l:=0 to 9 do
  2226.                 begin
  2227.                   if plansza_komputer[l+k*10].stale=1 then
  2228.                   begin
  2229.                     czy_wygral:=false;
  2230.                     break;
  2231.                   end;
  2232.                 end;
  2233.               end;
  2234.               if czy_wygral then
  2235.               begin
  2236.                 cleardevice;
  2237.                 settextstyle(defaultfont,horizdir,2);
  2238.                 outtextxy((getmaxx-textwidth('WYGRAL GRACZ')) div 2,getmaxy div 2,'WYGRAL GRACZ');
  2239.                 settextstyle(defaultfont,horizdir,1);
  2240.                 outtextxy((getmaxx-textwidth('Nacisnij dowolny klawisz, zeby kontynuowac...')) div 2,getmaxy div 2 + 4*textheight('WYGRAL GRACZ'),'Nacisnij dowolny klawisz, zeby kontynuowac...');
  2241.                 repeat until keypressed;
  2242.                 klawisz:=readkey;
  2243.                 cleardevice;
  2244.                 settextstyle(0,0,3);
  2245.                 exit;
  2246.               end;
  2247.             end;
  2248.             end;
  2249.           end;
  2250.           end;
  2251.           cleardevice;
  2252.           plansza_komputer[j+i*10].tmp:=4;
  2253.           rysuj(plansza_komputer,0,0);
  2254.           for k:=0 to 9 do
  2255.             begin
  2256.               for l:=0 to 9 do
  2257.               begin
  2258.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=4;
  2259.               end;
  2260.             end;
  2261.             rysuj(plansza_gracz1,12*szerokosc,0);
  2262.             for k:=0 to 9 do
  2263.             begin
  2264.               for l:=0 to 9 do
  2265.               begin
  2266.                 if plansza_gracz1[l+k*10].stale=1 then plansza_gracz1[l+k*10].tmp:=0;
  2267.               end;
  2268.             end;
  2269.           plansza_komputer[j+i*10].tmp:=0;
  2270.         end;
  2271.       end;
  2272.     end
  2273.     else
  2274.     begin
  2275.       while true do
  2276.       begin
  2277.         if statek_napoczety then
  2278.         begin
  2279.           if czy_zatopiony(plansza_gracz1,zapamietane_i,zapamietane_j) then
  2280.           begin
  2281.             statek_napoczety:=false;
  2282.             continue;
  2283.           end;
  2284.           orientacja:=0;
  2285.           if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=3) or (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=3) then orientacja:=1;
  2286.           if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=3) or (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=3) then orientacja:=2;
  2287.           if orientacja=0 then
  2288.           begin
  2289.             if zapamietane_i=0 then
  2290.             begin
  2291.               if zapamietane_j=0 then
  2292.               begin
  2293.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2294.                 begin
  2295.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2296.                   begin
  2297.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2298.                     continue;
  2299.                   end;
  2300.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2301.                   begin
  2302.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2303.                     break;
  2304.                   end;
  2305.                 end
  2306.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2307.                 begin
  2308.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2309.                   begin
  2310.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2311.                     continue;
  2312.                   end;
  2313.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2314.                   begin
  2315.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2316.                     break;
  2317.                   end;
  2318.                 end;
  2319.               end
  2320.               else if zapamietane_j=9 then
  2321.               begin
  2322.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2323.                 begin
  2324.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2325.                   begin
  2326.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2327.                     continue;
  2328.                   end;
  2329.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2330.                   begin
  2331.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2332.                     break;
  2333.                   end;
  2334.                 end
  2335.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2336.                 begin
  2337.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2338.                   begin
  2339.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2340.                     continue;
  2341.                   end;
  2342.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2343.                   begin
  2344.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2345.                     break;
  2346.                   end;
  2347.                 end;
  2348.               end
  2349.               else
  2350.               begin
  2351.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2352.                 begin
  2353.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2354.                   begin
  2355.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2356.                     continue;
  2357.                   end;
  2358.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2359.                   begin
  2360.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2361.                     break;
  2362.                   end;
  2363.                 end
  2364.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2365.                 begin
  2366.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2367.                   begin
  2368.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2369.                     continue;
  2370.                   end;
  2371.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2372.                   begin
  2373.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2374.                     break;
  2375.                   end;
  2376.                 end
  2377.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2378.                 begin
  2379.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2380.                   begin
  2381.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2382.                     continue;
  2383.                   end;
  2384.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2385.                   begin
  2386.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2387.                     break;
  2388.                   end;
  2389.                 end;
  2390.               end;
  2391.             end
  2392.             else if zapamietane_i=9 then
  2393.             begin
  2394.               if zapamietane_j=0 then
  2395.               begin
  2396.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2397.                 begin
  2398.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2399.                   begin
  2400.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2401.                     continue;
  2402.                   end;
  2403.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2404.                   begin
  2405.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2406.                     break;
  2407.                   end;
  2408.                 end
  2409.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2410.                 begin
  2411.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2412.                   begin
  2413.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2414.                     continue;
  2415.                   end;
  2416.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2417.                   begin
  2418.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2419.                     break;
  2420.                   end;
  2421.                 end;
  2422.               end
  2423.               else if zapamietane_j=9 then
  2424.               begin
  2425.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2426.                 begin
  2427.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2428.                   begin
  2429.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2430.                     continue;
  2431.                   end;
  2432.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2433.                   begin
  2434.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2435.                     break;
  2436.                   end;
  2437.                 end
  2438.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2439.                 begin
  2440.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2441.                   begin
  2442.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2443.                     continue;
  2444.                   end;
  2445.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2446.                   begin
  2447.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2448.                     break;
  2449.                   end;
  2450.                 end;
  2451.               end
  2452.               else
  2453.               begin
  2454.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2455.                 begin
  2456.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2457.                   begin
  2458.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2459.                     continue;
  2460.                   end;
  2461.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2462.                   begin
  2463.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2464.                     break;
  2465.                   end;
  2466.                 end
  2467.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2468.                 begin
  2469.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2470.                   begin
  2471.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2472.                     continue;
  2473.                   end;
  2474.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2475.                   begin
  2476.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2477.                     break;
  2478.                   end;
  2479.                 end
  2480.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2481.                 begin
  2482.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2483.                   begin
  2484.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2485.                     continue;
  2486.                   end;
  2487.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2488.                   begin
  2489.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2490.                     break;
  2491.                   end;
  2492.                 end;
  2493.               end;
  2494.             end
  2495.             else
  2496.             begin
  2497.               if zapamietane_j=0 then
  2498.               begin
  2499.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2500.                 begin
  2501.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2502.                   begin
  2503.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2504.                     continue;
  2505.                   end;
  2506.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2507.                   begin
  2508.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2509.                     break;
  2510.                   end;
  2511.                 end
  2512.                 else if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2513.                 begin
  2514.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2515.                   begin
  2516.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2517.                     continue;
  2518.                   end;
  2519.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2520.                   begin
  2521.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2522.                     break;
  2523.                   end;
  2524.                 end
  2525.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2526.                 begin
  2527.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2528.                   begin
  2529.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2530.                     continue;
  2531.                   end;
  2532.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2533.                   begin
  2534.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2535.                     break;
  2536.                   end;
  2537.                 end;
  2538.               end
  2539.               else if zapamietane_j=9 then
  2540.               begin
  2541.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2542.                 begin
  2543.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2544.                   begin
  2545.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2546.                     continue;
  2547.                   end;
  2548.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2549.                   begin
  2550.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2551.                     break;
  2552.                   end;
  2553.                 end
  2554.                 else if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2555.                 begin
  2556.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2557.                   begin
  2558.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2559.                     continue;
  2560.                   end;
  2561.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2562.                   begin
  2563.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2564.                     break;
  2565.                   end;
  2566.                 end
  2567.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2568.                 begin
  2569.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2570.                   begin
  2571.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2572.                     continue;
  2573.                   end;
  2574.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2575.                   begin
  2576.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2577.                     break;
  2578.                   end;
  2579.                 end;
  2580.               end
  2581.               else
  2582.               begin
  2583.                 if (plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale<>2) then
  2584.                 begin
  2585.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=1 then
  2586.                   begin
  2587.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=3;
  2588.                     continue;
  2589.                   end;
  2590.                   if plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale=0 then
  2591.                   begin
  2592.                     plansza_gracz1[zapamietane_j+(zapamietane_i-1)*10].stale:=2;
  2593.                     break;
  2594.                   end;
  2595.                 end
  2596.                 else if (plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>3)and(plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale<>2) then
  2597.                 begin
  2598.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=1 then
  2599.                   begin
  2600.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=3;
  2601.                     continue;
  2602.                   end;
  2603.                   if plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale=0 then
  2604.                   begin
  2605.                     plansza_gracz1[zapamietane_j+(zapamietane_i+1)*10].stale:=2;
  2606.                     break;
  2607.                   end;
  2608.                 end
  2609.                 else if (plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale<>2) then
  2610.                 begin
  2611.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=1 then
  2612.                   begin
  2613.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=3;
  2614.                     continue;
  2615.                   end;
  2616.                   if plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale=0 then
  2617.                   begin
  2618.                     plansza_gracz1[zapamietane_j+1+zapamietane_i*10].stale:=2;
  2619.                     break;
  2620.                   end;
  2621.                 end
  2622.                 else if (plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>3)and(plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale<>2) then
  2623.                 begin
  2624.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=1 then
  2625.                   begin
  2626.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=3;
  2627.                     continue;
  2628.                   end;
  2629.                   if plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale=0 then
  2630.                   begin
  2631.                     plansza_gracz1[zapamietane_j-1+zapamietane_i*10].stale:=2;
  2632.                     break;
  2633.                   end;
  2634.                 end;
  2635.               end;
  2636.             end;
  2637.  
  2638.           end
  2639.           else if orientacja=1 then
  2640.           begin
  2641.             przerwanie:=false;
  2642.             for iterator:=zapamietane_i to 9 do
  2643.             begin
  2644.               if plansza_gracz1[zapamietane_j+iterator*10].stale=2 then
  2645.               begin
  2646.                 break;
  2647.               end
  2648.               else if plansza_gracz1[zapamietane_j+iterator*10].stale=0 then
  2649.               begin
  2650.                 plansza_gracz1[zapamietane_j+iterator*10].stale:=2;
  2651.                 przerwanie:=true;
  2652.                 break;
  2653.               end
  2654.               else if plansza_gracz1[zapamietane_j+iterator*10].stale=1 then
  2655.               begin
  2656.                 plansza_gracz1[zapamietane_j+iterator*10].stale:=3;
  2657.                 if czy_zatopiony(plansza_gracz1,zapamietane_i,zapamietane_j) then
  2658.                 begin
  2659.                   statek_napoczety:=false;
  2660.                   continue;
  2661.                 end;
  2662.               end;
  2663.             end;
  2664.             if przerwanie then break;
  2665.             for iterator:=zapamietane_i downto 0 do
  2666.             begin
  2667.               if plansza_gracz1[zapamietane_j+iterator*10].stale=2 then
  2668.               begin
  2669.                 break;
  2670.               end
  2671.               else if plansza_gracz1[zapamietane_j+iterator*10].stale=0 then
  2672.               begin
  2673.                 plansza_gracz1[zapamietane_j+iterator*10].stale:=2;
  2674.                 przerwanie:=true;
  2675.                 break;
  2676.               end
  2677.               else if plansza_gracz1[zapamietane_j+iterator*10].stale=1 then
  2678.               begin
  2679.                 plansza_gracz1[zapamietane_j+iterator*10].stale:=3;
  2680.                 if czy_zatopiony(plansza_gracz1,zapamietane_i,zapamietane_j) then
  2681.                 begin
  2682.                   statek_napoczety:=false;
  2683.                   continue;
  2684.                 end;
  2685.               end;
  2686.             end;
  2687.             if przerwanie then break;
  2688.           end
  2689.           else if orientacja=2 then
  2690.           begin
  2691.             przerwanie:=false;
  2692.             for iterator:=zapamietane_j to 9 do
  2693.             begin
  2694.               if plansza_gracz1[iterator+zapamietane_i*10].stale=2 then
  2695.               begin
  2696.                 break;
  2697.               end
  2698.               else if plansza_gracz1[iterator+zapamietane_i*10].stale=0 then
  2699.               begin
  2700.                 plansza_gracz1[iterator+zapamietane_i*10].stale:=2;
  2701.                 przerwanie:=true;
  2702.                 break;
  2703.               end
  2704.               else if plansza_gracz1[iterator+zapamietane_i*10].stale=1 then
  2705.               begin
  2706.                 plansza_gracz1[iterator+zapamietane_i*10].stale:=3;
  2707.                 if czy_zatopiony(plansza_gracz1,zapamietane_i,zapamietane_j) then
  2708.                 begin
  2709.                   statek_napoczety:=false;
  2710.                   continue;
  2711.                 end;
  2712.               end;
  2713.             end;
  2714.             if przerwanie then break;
  2715.             for iterator:=zapamietane_j downto 0 do
  2716.             begin
  2717.               if plansza_gracz1[iterator+zapamietane_i*10].stale=2 then
  2718.               begin
  2719.                 break;
  2720.               end
  2721.               else if plansza_gracz1[iterator+zapamietane_i*10].stale=0 then
  2722.               begin
  2723.                 plansza_gracz1[iterator+zapamietane_i*10].stale:=2;
  2724.                 przerwanie:=true;
  2725.                 break;
  2726.               end
  2727.               else if plansza_gracz1[iterator+zapamietane_i*10].stale=1 then
  2728.               begin
  2729.                 plansza_gracz1[iterator+zapamietane_i*10].stale:=3;
  2730.                 if czy_zatopiony(plansza_gracz1,zapamietane_i,zapamietane_j) then
  2731.                 begin
  2732.                   statek_napoczety:=false;
  2733.                   continue;
  2734.                 end;
  2735.               end;
  2736.             end;
  2737.             if przerwanie then break;
  2738.           end;
  2739.         end
  2740.         else
  2741.         begin
  2742.           i:=random(10);
  2743.           j:=random(10);
  2744.           if plansza_gracz1[j+i*10].stale=0 then
  2745.           begin
  2746.             plansza_gracz1[j+i*10].stale:=2;
  2747.             break;
  2748.           end
  2749.           else if plansza_gracz1[j+i*10].stale=1 then
  2750.           begin
  2751.             statek_napoczety:=true;
  2752.             zapamietane_i:=i;
  2753.             zapamietane_j:=j;
  2754.             plansza_gracz1[j+i*10].stale:=3;
  2755.             czy_zatopiony(plansza_gracz1,i,j);
  2756.             czy_wygral:=true;
  2757.             for k:=0 to 9 do
  2758.             begin
  2759.               for l:=0 to 9 do
  2760.               begin
  2761.                 if plansza_gracz1[l+k*10].stale=1 then
  2762.                 begin
  2763.                   czy_wygral:=false;
  2764.                   break;
  2765.                 end;
  2766.               end;
  2767.             end;
  2768.             if czy_wygral then
  2769.             begin
  2770.               cleardevice;
  2771.               settextstyle(defaultfont,horizdir,2);
  2772.               outtextxy((getmaxx-textwidth('WYGRAL KOMPUTER')) div 2,getmaxy div 2,'WYGRAL KOMPUTER');
  2773.               settextstyle(defaultfont,horizdir,1);
  2774.               outtextxy((getmaxx-textwidth('Nacisnij dowolny klawisz, zeby kontynuowac...')) div 2,getmaxy div 2 + 4*textheight('WYGRAL KOMPUTER'),'Nacisnij dowolny klawisz, zeby kontynuowac...');
  2775.               repeat until keypressed;
  2776.               klawisz:=readkey;
  2777.               cleardevice;
  2778.               settextstyle(0,0,3);
  2779.               exit;
  2780.             end;
  2781.           end;
  2782.         end;
  2783.       end;
  2784.     end;
  2785.     inc(licznik);
  2786.   end;
  2787. end;
  2788.  
  2789. procedure menu;
  2790. var
  2791.   licznik:word;
  2792.   klawisz:char;
  2793. begin
  2794.   settextstyle(0,0,3);
  2795.   licznik:=1;
  2796.   while true do
  2797.   begin
  2798.     if keypressed then
  2799.     begin
  2800.       klawisz:=readkey;
  2801.       case klawisz of
  2802.       #80:if licznik<3 then inc(licznik);                        //strzalka w dol
  2803.       #72:if licznik>1 then dec(licznik);                        //strzalka w gore
  2804.       #13:
  2805.       begin
  2806.         cleardevice;
  2807.         case licznik of
  2808.         1:pvp;
  2809.         2:pve;
  2810.         3:
  2811.         begin
  2812.           if koniec=true then exit;
  2813.         end;
  2814.         end;
  2815.       end;
  2816.       end;
  2817.     end;
  2818.  
  2819.     case licznik of               //ustalnie koloru podswietlenia
  2820.     1:
  2821.     begin
  2822.       setcolor(red);
  2823.       outtextxy((getmaxx-textwidth('GRACZ VS GRACZ'))div 2,getmaxy div 2 - 2*textheight('GRACZ VS KOMPUTER'),'GRACZ VS GRACZ');
  2824.       setcolor(white);
  2825.       outtextxy((getmaxx-textwidth('GRACZ VS KOMPUTER'))div 2,getmaxy div 2,'GRACZ VS KOMPUTER');
  2826.       outtextxy((getmaxx-textwidth('WYJSCIE'))div 2,getmaxy div 2 + 2*textheight('GRACZ VS KOMPUTER'),'WYJSCIE');
  2827.     end;
  2828.     2:
  2829.     begin
  2830.       setcolor(white);
  2831.       outtextxy((getmaxx-textwidth('GRACZ VS GRACZ'))div 2,getmaxy div 2 - 2*textheight('GRACZ VS KOMPUTER'),'GRACZ VS GRACZ');
  2832.       setcolor(red);
  2833.       outtextxy((getmaxx-textwidth('GRACZ VS KOMPUTER'))div 2,getmaxy div 2,'GRACZ VS KOMPUTER');
  2834.       setcolor(white);
  2835.       outtextxy((getmaxx-textwidth('WYJSCIE'))div 2,getmaxy div 2 + 2*textheight('GRACZ VS KOMPUTER'),'WYJSCIE');
  2836.     end;
  2837.     3:
  2838.     begin
  2839.       setcolor(white);
  2840.       outtextxy((getmaxx-textwidth('GRACZ VS GRACZ'))div 2,getmaxy div 2 - 2*textheight('GRACZ VS KOMPUTER'),'GRACZ VS GRACZ');
  2841.       outtextxy((getmaxx-textwidth('GRACZ VS KOMPUTER'))div 2,getmaxy div 2,'GRACZ VS KOMPUTER');
  2842.       setcolor(red);
  2843.       outtextxy((getmaxx-textwidth('WYJSCIE'))div 2,getmaxy div 2 + 2*textheight('GRACZ VS KOMPUTER'),'WYJSCIE');
  2844.     end;
  2845.     end;
  2846. end;
  2847. end;
  2848.  
  2849. begin
  2850.   driver:=VGA;
  2851.   mode:=VGAHi;
  2852.   initgraph(driver,mode,'');
  2853.   intro;
  2854.   menu;
  2855. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement