{ SACH.PAS Copyright (c) Miro Kuki } { } { Je tu koneŔne Üach pre dvoch (sÝce s hroznou grafilkou, ale Ŕo u×)} { Ovlßdanie je veżmi jednoduchÚ pohybuje sa pomocou: } { ő Ŕo umo×nÝ pohyb smerom do żava } { í Ŕo umo×nÝ pohyb smerom dolu } { Ť Ŕo umo×nÝ pohyb smerom do prava } { ^ Ŕo umo×nÝ pohyb smerom nahor } { medzernÝk Ŕo umo×nÝ zobratie fig˙rky } { } { V - znamenß ve×a } { K - znamenß k˘˛ } { S - znamenß strelec } { Q - znamenß krßżovna } { + - znamenß krßż, s ktorřm sa eÜte nepohlo } { R - znamenß krßż, s ktorřm sa pohlo } { P - znamenß peÜiak } { } { Pre ukonŔenie nßpovedy stisnite "ENTER" a pre ukonŔenie hry } { stisnite k (ale a× po tom,ako stlaŔÝte "ENTER" ) } { Prajem prÝjenu zßbavu } { } { Author: Miro Kuki } { Date : 28.8.2006 http://www.trsek.com } program sach; uses crt; const biely = 15; cierny = 9; minx = 30; {Určuje, kde sa nachádza prvý bod} miny = 10; hlaska = 12; z = 15; vy = 14; ak = 13; ine = 11; koniec = 12; var sachovnica : array [minx..minx+16,miny..miny+16] of char; {tu sa uklada, či ide o čierneho alebo bieleho} pole : array [minx..minx+16,miny..miny+16] of char; poradie : byte; pomocna : char; p : char; x,y : byte; px,py : byte; nic : char; j,i : integer; {na vymazanie sachovnice, ale dá sa hocikde použiť} ozaj : boolean; kral1pohyb,kral2pohyb : boolean; prvytah : array [1..16,1..2] of boolean;{pre prvy tah pesiaka} e,f : byte; koniechry : boolean; Function zistenieciniektonevyhral:boolean; var a,b,c:byte; begin c:=0; zistenieciniektonevyhral:=false; for a:=miny to miny+16 do for b:=minx to minx+16 do begin if sachovnica[b,a] = '┼' then inc(c); end; if c < 2 then zistenieciniektonevyhral:=true; end; Procedure pohyb; begin case p of 'H': dec(y,2); 'P': inc(y,2); 'K': dec(x,2); 'M': inc(x,2); end; if x >= minx+17 then x:=minx+2; if x <= minx then x:=minx+16; if y >= miny+17 then y:=miny+2; if y <= miny then y:=miny+16; end; Procedure vymena; var proc:boolean; begin proc:=true; if pomocna = 'P' then begin if (y = 12) or (y = 26) then begin repeat gotoxy(35,30); write('Napíš ktorú chceš figúrku: '); readln(pomocna); case pomocna of 'v': begin if poradie = 1 then pole[x,y]:='c' else pole[x,y]:='b'; pomocna:='V'; proc:=true; end; 'q': begin if poradie = 1 then pole[x,y]:='c' else pole[x,y]:='b'; pomocna:='Q'; proc:=true; end; 's': begin if poradie = 1 then pole[x,y]:='c' else pole[x,y]:='b'; pomocna:='S'; proc:=true; end; 'k': begin if poradie = 1 then pole[x,y]:='c' else pole[x,y]:='b'; pomocna:='K'; proc:=true; end; else begin proc:=false; gotoxy(46,30); write(' '); end; end; until proc=true; end; end; gotoxy(35,30); write(' '); end; Function skusp:boolean; {pre pešiakov} begin skusp:=false; if pomocna = 'P' then begin f:=(px-minx); if poradie = 1 then begin {Zaciatok cierneho} if ((pole[x,y] = 'b') and ((px = x+2) and (py = y+2))) or ((pole[x,y] = 'b') and ((px = x-2) and (py = y+2))) then skusp:=false else begin if ((py >= (y+4)) and (prvytah[f,2] = true)) or ((py >= (y+6)) and (prvytah[f,2] = false)) or (pole[x,y] = 'c') or (py < y) or ((pole[x,y] = ' ') and (px <> x)) or ((pole[x,y] = ' ') and (py = y)) or ((pole[x,y] = 'b') and (px = x)) or ((pole[x,y] = 'b') and (py = y)) or (pole[x,y] = 'c') or (px <> x) then begin skusp:=true; y:=py; x:=px; textcolor(cierny); end; end; end {koniec cierneho} else {Zaciatok bieleho} begin if ((pole[x,y] = 'c') and ((px = x+2) and (py = y-2))) or ((pole[x,y] = 'c') and ((px = x-2) and (py = y-2))) then skusp:=false else begin if ((py <= (y-4)) and (prvytah[f,1] = true)) or ((py <= (y-6)) and (prvytah[f,1] = false)) or (pole[x,y] = 'b') or (py > y) or ((pole[x,y] = ' ') and (px <> x)) or ((pole[x,y] = ' ') and (py = y)) or ((pole[x,y] = 'c') and (px = x)) or ((pole[x,y] = 'c') and (py = y)) or (pole[x,y] = 'b') or (px <> x) then begin skusp:=true; y:=py; x:=px; textcolor(biely); end; end; end; {Koniec Bieleho} end; vymena; {odkaz na proceduru, ktorá vymení pešiaka za niečo ine} end; Function skusv:boolean; {pre vežu} begin skusv:=false; if pomocna = 'V' then begin if poradie = 1 then begin {Skuska, či niekto nestojí v ceste} if px > x then {doľva} for i:=x+1 to px do if pole[i,y] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(cierny); end; if px < x then {doprava} for i:=px to x-1 do begin if pole[i,y] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(cierny); end; end; if py > y then {hore} for i:=y+1 to py do if pole[x,i] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(cierny); end; if py < y then {dolu} for i:=py to y-1 do begin if pole[x,i] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(cierny); end; end; {Koniec preskakovania} if (py <> y) and (px <> x) or (py = y) and (px = x) or (pole[x,y] = 'c') or (pole[x,y] = 'c') then begin skusv:=true; y:=py; x:=px; textcolor(cierny); end end else begin {preskakovanie} if px > x then {doľva} for i:=x+1 to px do if pole[i,y] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(biely); end; if px < x then {doprava} for i:=px to x-1 do begin if pole[i,y] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(biely); end; end; if py > y then {hore} for i:=y+1 to py do if pole[x,i] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(biely); end; if py < y then {dolu} for i:=py to y-1 do begin if pole[x,i] <> ' ' then begin skusv:=true; y:=py; x:=px; textcolor(biely); end; end; {Koniec preskakovania} if (py <> y) and (px <> x) or (py = y) and (px = x) or (pole[x,y] = 'b') or (pole[x,y] = 'b') then begin skusv:=true; y:=py; x:=px; textcolor(biely); end; end; end; end; Function skuss:boolean; {pre strelca} var k:byte; begin skuss:=false; if pomocna = 'S' then begin {ci nieco nestojí v ceste} j:=0; if (x > px) and (py < y) then for i:=px to x-1 do begin k:=py+j; if pole[i,k] <> ' ' then begin skuss:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; j:=-1; if (px > x) and (py < y) then for i:=x+1 to px do begin k:=y+j; if pole[i,k] <> ' ' then begin skuss:=true; i:=px; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; dec(j); end; j:=0; if (x > px) and (py > y) then for i:=px to x-1 do begin k:=py-j; if pole[i,k] <> ' ' then begin skuss:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; j:=1; if (px > x) and (py > y) then for i:=x+1 to px do begin k:=y+j; if pole[i,k] <> ' ' then begin skuss:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; {už vieme či niečo stjí v ceste, alebo nie} if poradie = 1 then begin if (abs(py-y) <> abs(px-x)) or (py = y) and (px = x) or (pole[x,y] = 'c') or (pole[x,y] = 'c') then begin skuss:=true; y:=py; x:=px; textcolor(cierny); end end else begin if (abs(py-y) <> abs(px-x)) or (py = y) and (px = x) or (pole[x,y] = 'b') or (pole[x,y] = 'b') then begin skuss:=true; y:=py; x:=px; textcolor(biely); end; end; end; end; Function skusk:boolean; {pre koňa} begin skusk:=false; if pomocna = 'K' then begin if poradie = 1 then begin if (py <> y-4) or (px <> x+2) or (pole[x,y] = 'c') then begin if (py <> y-4) or (px <> x-2) or (pole[x,y] = 'c') then begin if (px <> x-4) or (py <> y+2) or (pole[x,y] = 'c') then begin if (px <> x-4) or (py <> y-2) or (pole[x,y] = 'c') then begin if (py <> y+4) or (px <> x+2) or (pole[x,y] = 'c') then begin if ((py <> y+4) or (px <> x-2)) or (pole[x,y] = 'c') then begin if ((px <> x+4) or (py <> y+2)) or (pole[x,y] = 'c') then begin if ((px <> x+4) or (py <> y-2)) or (pole[x,y] = 'c') then begin skusk:=true; y:=py; x:=px; textcolor(cierny); end; end; end; end; end; end; end; end; end else begin if (py <> y-4) or (px <> x+2) or (pole[x,y] = 'b') then begin if (py <> y-4) or (px <> x-2) or (pole[x,y] = 'b') then begin if (px <> x-4) or (py <> y+2) or (pole[x,y] = 'b') then begin if (px <> x-4) or (py <> y-2) or (pole[x,y] = 'b') then begin if (py <> y+4) or (px <> x+2) or (pole[x,y] = 'b') then begin if ((py <> y+4) or (px <> x-2)) or (pole[x,y] = 'b') then begin if ((px <> x+4) or (py <> y+2)) or (pole[x,y] = 'b') then begin if ((px <> x+4) or (py <> y-2)) or (pole[x,y] = 'b') then begin skusk:=true; y:=py; x:=px; textcolor(biely); end; end; end; end; end; end; end; end; end; end; end; Function skusq:boolean; {pre kráľovnu} var k:byte; begin skusq:=false; if pomocna = 'Q' then begin if poradie = 1 then begin if (py <> y) and (px = x) and (pole[x,y] <> 'c') or (py = y) and (px <> x) and (pole[x,y] <> 'c') then skusq:=false else begin if (abs(py-y) <> abs(px-x)) or (py = y) and (px = x) or (pole[x,y] = 'c') then begin skusq:=true; y:=py; x:=px; textcolor(cierny); end; end; end else begin if (py <> y) and (px = x) and (pole[x,y] <> 'b') or (py = y) and (px <> x) and (pole[x,y] <> 'b') then skusq:=false else begin if (abs(py-y) <> abs(px-x)) or (py = y) and (px = x) or (pole[x,y] = 'b') then begin skusq:=true; y:=py; x:=px; textcolor(biely); end; end; end; if skusq = true then else begin {Skuska, či niekto nestojí v ceste vodorovne a zvysle} if (abs(py-y) <> abs(px-x)) then begin if px > x then {doľva} for i:=x+1 to px do if pole[i,y] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; if px < x then {doprava} for i:=px to x-1 do begin if pole[i,y] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; end; if py > y then {hore} for i:=y+1 to py do if pole[x,i] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; if py < y then {dolu} for i:=py to y-1 do begin if pole[x,i] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; end; end else {Koniec vertikálneho a horizontálneho zisťovania} begin j:=0; {Zisťovanie či nieco nestojí v šikmej ceste} if (x > px) and (py < y) then for i:=px to x-1 do begin k:=py+j; if pole[i,k] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; j:=-1; if (px > x) and (py < y) then for i:=x+1 to px do begin k:=y+j; if pole[i,k] <> ' ' then begin skusq:=true; i:=px; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; dec(j); end; j:=0; if (x > px) and (py > y) then for i:=px to x-1 do begin k:=py-j; if pole[i,k] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; j:=1; if (px > x) and (py > y) then for i:=x+1 to px do begin k:=y+j; if pole[i,k] <> ' ' then begin skusq:=true; y:=py; x:=px; if poradie = 1 then textcolor(cierny) else textcolor(biely); end; inc(j); end; end; {už vieme či niečo stjí v ceste, alebo nie} end; end; end; Function skuskr:boolean; {pre kráľa} begin skuskr:=false; if pomocna = '┼' then begin if (kral1pohyb = false) and (poradie = 0) or (kral2pohyb = false) and (poradie = 1) then begin if (px <= x-2) or (px >= x+2) or (py >= y+2) or (py <= y-2) then begin if poradie = 1 then begin if (pole[x,y] = 'c') then begin skuskr:=true; y:=py; x:=px; textcolor(cierny); end else begin if (py = y-2) and (px = x) {zaciatok vodorovne a zvysle} or ((py = y+2) and (px = x)) or ((py = y) and (px = x+2)) or ((py = y) and (px = x-2)) {koniec vodorovne a zvysle} or ((py = y-2) and (px = x-2)) {zaciatok kríž} or ((py = y-2) and (px = x+2)) or ((py = y+2) and (px = x-2)) {koniec kríž + to potom} or ((py = y+2) and (px = x+2)) or ((px = x-4) and (py = y)) or ((px = x+4) and (py = y)) then begin skuskr:=false; end else begin skuskr:=true; y:=py; x:=px; textcolor(cierny); end; end; end else begin if (pole[x,y] = 'b') then begin skuskr:=true; y:=py; x:=px; textcolor(biely); end else begin if (py = y-2) and (px = x) {zaciatok vodorovne a zvysle} or ((py = y+2) and (px = x)) or ((py = y) and (px = x+2)) or ((py = y) and (px = x-2)) {koniec vodorovne a zvysle} or ((py = y-2) and (px = x-2)) {zaciatok kríž} or ((py = y-2) and (px = x+2)) or ((py = y+2) and (px = x-2)) {koniec kríž + to potom} or ((py = y+2) and (px = x+2)) or ((px = x-4) and (py = y)) or ((px = x+4) and (py = y)) then begin skuskr:=false; end else begin skuskr:=true; y:=py; x:=px; textcolor(biely); end; end; end; end; {ROšáDA} if (px = x-4) and (py = y) then {doprava} begin if poradie = 1 then begin if pole[42,26] <> ' ' then skuskr:=true else begin {kráľ} pole[40,26]:=' '; pole[44,26]:='c'; sachovnica[40,26]:=' '; sachovnica[44,26]:='┼'; {veža} pole[46,26]:=' '; pole[42,26]:='c'; sachovnica[46,26]:=' '; sachovnica[42,26]:='V'; gotoxy(46,26);write(' '); textcolor(cierny); gotoxy(42,26);write('V'); end; end else begin if pole[42,12] <> ' ' then skuskr:=true else begin {kráľ} pole[40,12]:=' '; pole[44,12]:='b'; sachovnica[40,12]:=' '; sachovnica[44,12]:='┼'; {veža} pole[46,12]:=' '; pole[42,12]:='b'; sachovnica[46,12]:=' '; sachovnica[42,12]:='V'; gotoxy(46,12);write(' '); gotoxy(42,12);write('V'); end; end; end; if (px = x+4) and (py = y) then {doľava} begin if poradie = 1 then begin if pole[38,26] <> ' ' then skuskr:=true else begin {kráľ} pole[40,26]:=' '; pole[36,26]:='c'; sachovnica[32,26]:=' '; sachovnica[36,26]:='┼'; {veža} pole[32,26]:=' '; pole[38,26]:='c'; sachovnica[32,26]:=' '; sachovnica[38,26]:='V'; gotoxy(32,26);write(' '); textcolor(cierny); gotoxy(38,26);write('V'); end; end else begin if pole[38,12] <> ' ' then skuskr:=true else begin {kráľ} pole[40,12]:=' '; pole[36,12]:='b'; sachovnica[40,12]:=' '; sachovnica[36,12]:='┼'; {veža} pole[32,12]:=' '; pole[38,12]:='b'; sachovnica[32,12]:=' '; sachovnica[38,12]:='V'; gotoxy(32,12);write(' '); gotoxy(38,12);write('V'); end; end; end; end else begin if poradie = 1 then begin if (pole[x,y] = 'c') then begin skuskr:=true; y:=py; x:=px; textcolor(cierny); end else begin if (py = y-2) and (px = x) {zaciatok vodorovne a zvysle} or ((py = y+2) and (px = x)) or ((py = y) and (px = x+2)) or ((py = y) and (px = x-2)) {koniec vodorovne a zvysle} or ((py = y-2) and (px = x-2)) {zaciatok kríž} or ((py = y-2) and (px = x+2)) or ((py = y+2) and (px = x-2)) {koniec kríž + to potom} or ((py = y+2) and (px = x+2)) then begin skuskr:=false; end else begin skuskr:=true; y:=py; x:=px; textcolor(cierny); end; end; end else begin if (pole[x,y] = 'b') then begin skuskr:=true; y:=py; x:=px; textcolor(biely); end else begin if (py = y-2) and (px = x) {zaciatok vodorovne a zvysle} or ((py = y+2) and (px = x)) or ((py = y) and (px = x+2)) or ((py = y) and (px = x-2)) {koniec vodorovne a zvysle} or ((py = y-2) and (px = x-2)) {zaciatok kríž} or ((py = y-2) and (px = x+2)) or ((py = y+2) and (px = x-2)) {koniec kríž + to potom} or ((py = y+2) and (px = x+2)) then begin skuskr:=false; end else begin skuskr:=true; y:=py; x:=px; textcolor(biely); end; end; end; end; end; if (px = x) and (py = y) then skuskr:=true; end; {Usporiadanie figuriek} Procedure figurkyb; {IBA PRE ZAČIATOK} var c,d:byte; begin d:=miny+4; c:=minx; e:=1; repeat inc(c,2); gotoxy(c,d); textcolor(biely); write('P'); sachovnica[c,d]:='P'; pole[c,d]:='b'; inc(e); prvytah[e,1]:=false; until c>=minx+16; d:=miny+2; c:=minx+2; gotoxy(c,d); write('V'); sachovnica[c,d]:='V'; pole[c,d]:='b'; gotoxy(c+2,d); write('K'); sachovnica[c+2,d]:='K'; pole[c+2,d]:='b'; gotoxy(c+4,d); write('S'); sachovnica[c+4,d]:='S'; pole[c+4,d]:='b'; gotoxy(c+6,d); write('Q'); sachovnica[c+6,d]:='Q'; pole[c+6,d]:='b'; gotoxy(c+8,d); write('┼'); sachovnica[c+8,d]:='┼'; pole[c+8,d]:='b'; gotoxy(c+10,d); write('S'); sachovnica[c+10,d]:='S'; pole[c+10,d]:='b'; gotoxy(c+12,d); write('K'); sachovnica[c+12,d]:='K'; pole[c+12,d]:='b'; gotoxy(c+14,d); write('V'); sachovnica[c+14,d]:='V'; pole[c+14,d]:='b'; end; Procedure figurkyc; var c,d:byte; begin d:=miny+14; c:=minx; e:=1; repeat inc(c,2); gotoxy(c,d); textcolor(cierny); write('P'); sachovnica[c,d]:='P'; pole[c,d]:='c'; inc(e); prvytah[e,2]:=false until c>=minx+16; d:=miny+16; c:=minx+2; gotoxy(c,d); write('V'); sachovnica[c,d]:='V'; pole[c,d]:='c'; gotoxy(c+2,d); write('K'); sachovnica[c+2,d]:='K'; pole[c+2,d]:='c'; gotoxy(c+4,d); write('S'); sachovnica[c+4,d]:='S'; pole[c+4,d]:='c'; gotoxy(c+6,d); write('Q'); sachovnica[c+6,d]:='Q'; pole[c+6,d]:='c'; gotoxy(c+8,d); write('┼'); sachovnica[c+8,d]:='┼'; pole[c+8,d]:='c'; gotoxy(c+10,d); write('S'); sachovnica[c+10,d]:='S'; pole[c+10,d]:='c'; gotoxy(c+12,d); write('K'); sachovnica[c+12,d]:='K'; pole[c+12,d]:='c'; gotoxy(c+14,d); write('V'); sachovnica[c+14,d]:='V'; pole[c+14,d]:='c'; end; Procedure mriezka; {Nakreslí hracie pole} var a,b:byte; begin a:=miny+1; b:=minx+1; gotoxy(b,a); writeln('┌─┬─┬─┬─┬─┬─┬─┬─┐'); gotoxy(b,a+1); writeln('│ │ │ │ │ │ │ │ │'); repeat inc(a,2); gotoxy(b,a); writeln('├─┼─┼─┼─┼─┼─┼─┼─┤'); gotoxy(b,a+1); writeln('│ │ │ │ │ │ │ │ │'); until a>=miny+15; gotoxy(b,a+2); writeln('└─┴─┴─┴─┴─┴─┴─┴─┘'); end; Procedure napoveda; begin if p = 'h' then begin clrscr; textcolor(z); writeln('Je tu konečne šach pre dvoch (síce s hroznou grafilkou, ale čo už)'); writeln('Ovládanie je veľmi jednoduché pohybuje sa pomocou: '); textcolor(vy); {tu začína návod hry} write(chr(27)); textcolor(z); write(' čo umožní pohyb smerom '); textcolor(ak); writeln('do ľava'); textcolor(vy); write(chr(25)); textcolor(z); write(' čo umožní pohyb smerom '); textcolor(ak); writeln('dolu'); textcolor(vy); write(chr(26)); textcolor(z); write(' čo umožní pohyb smerom '); textcolor(ak); writeln('do prava'); textcolor(vy); write(chr(24)); textcolor(z); write(' čo umožní pohyb smerom '); textcolor(ak); writeln('nahor'); textcolor(vy); {návod na znak až po návod na ukončenie programu} write('medzerník'); textcolor(z); write(' čo umožní '); textcolor(ak); write(' zobratie '); textcolor(z); writeln('figúrky '); writeln; writeln('V - znamená veža'); writeln('K - znamená kôň'); writeln('S - znamená strelec'); writeln('Q - znamená kráľovna'); writeln('┼ - znamená kráľ, s ktorým sa ešte nepohlo'); writeln('R - znamená kráľ, s ktorým sa pohlo'); writeln('P - znamená pešiak'); writeln; textcolor(z); write('Pre ukončenie nápovedy stisnite'); textcolor(ine); write(' "ENTER" '); textcolor(z); {ukončenie hry} write('a pre ukončenie hry stisnite '); textcolor(ine); write('k '); textcolor(z); write('(ale až po tom,ako stlačíte '); textcolor(ine); write('"ENTER" '); textcolor(z); writeln(')'); writeln('Prajem príjenu zábavu'); readln; {tu končí návod hry} end; end; Procedure vymaz; begin for j:=minx to minx+16 do for i:=miny to miny+16 do begin sachovnica[j,i]:=' '; pole[j,i]:=' '; end; end; begin textmode(CO80 + Font8x8); clrscr; vymaz; x:=minx+8; y:=miny+2; write('Pre nápovedu stlač "H" a pre zahájenie hry "ENTER" '); readln(p); if p = 'h' then napoveda; clrscr; mriezka; figurkyb; figurkyc; poradie:=0; kral1pohyb:=false; kral2pohyb:=false; koniechry :=false; repeat if poradie = 1 then begin gotoxy(30,1); textcolor(hlaska); write('na tahu je cierny '); end else begin gotoxy(30,1); textcolor(hlaska); write('na tahu je biely '); end; repeat pomocna:=' '; gotoxy(30,40); textcolor(hlaska); write('Vybrata figurka: '); textbackground(8); textcolor(z); write(pomocna); gotoxy(x,y); p:=readkey; pohyb; gotoxy(x,y); if poradie = 1 then begin if pole[x,y] = 'c' then ozaj:=false else ozaj:=true; end else begin if pole[x,y] = 'b' then ozaj:=false else ozaj:=true; end; if p = ' ' then begin if (sachovnica[x,y] = ' ') or (ozaj = true) then begin gotoxy(47,40); writeln(' '); end else begin pomocna:=sachovnica[x,y]; sachovnica[x,y]:=' '; pole[x,y]:=' '; gotoxy(x,y); write(' '); gotoxy(30,40); textcolor(hlaska); write('Vybrata figurka: '); textbackground(8); textcolor(z); write(pomocna); px:=x; py:=y; repeat gotoxy(x,y); p:=readkey; if p = ' ' then begin if (skusk = false) and (skusv = false) and (skuss = false) and (skusq = false) and (skuskr= false) and (skusp = false) then begin if (pomocna = '┼') then {aby sa nedala robiť rošada po pohnutí s kráľom} begin if poradie = 1 then kral2pohyb:=true else kral1pohyb:=true; end; if (pomocna = 'P') then {aby sa nepohýňal s 1 pesiakom o 2 policka} begin if poradie = 1 then prvytah[f,2]:=true else prvytah[f,1]:=true; end; gotoxy(x,y); if poradie = 0 then begin sachovnica[x,y]:=pomocna; textcolor(biely); {ak chces ist bez cierneho, len biely tak o riadok nizsie zmen na 0} poradie:=1; {zmen na 1, ale len toto a uz moze ist aj cierny} pole[x,y]:='b'; end else begin sachovnica[x,y]:=pomocna; textcolor(cierny); poradie:=0; pole[x,y]:='c'; end; writeln(sachovnica[x,y]); if zistenieciniektonevyhral = true then begin clrscr; koniechry:=true; textcolor(koniec); gotoxy(30,20); if poradie = 1 then write('VYHRAL BIELY') else write('VYHRAL CIERNY'); readln; end; end else begin x:=px; y:=py; gotoxy(x,y); write(pomocna); sachovnica[x,y]:=pomocna; if poradie = 1 then pole[x,y]:='c' else pole[x,y]:='b'; sound(2000); delay(100); nosound; end; end else pohyb; if koniechry = true then p:=' '; until p = ' '; end; end; until (p = ' ') or (p = 'k'); if koniechry = true then p:='k'; until p = 'k'; delay(100); end.