Ahoj,
potreboval bych poradit. Delal jsem hru lode, kde se do pole zada jedna lod.
Zadavani a ukladani do pole funguje, ale bohuzel uz nefunguje zapisovani do pole kdyz se strili.
Proste mi to do toho "strileciho" pole nezapisuje.
Poradi mi prosim nekdo??
Diky moc.
program lode;
{$APPTYPE CONSOLE}
uses
SysUtils;
const m=3; n=3;
type
pole=array[1..m,1..n] of integer;
var pole1, pole2, polepalba1, polepalba2:pole;
hrac1, hrac2:string;
hrac, lode2, lode1, pocet, radek1, sloupec1, radek2, sloupec2, radek1palba, sloupec1palba, radek2palba, sloupec2palba: integer;
begin
{ TODO -oUser -cConsole Main : Insert code here }
writeln ('Vitejte ve hre LODE. Preji prijemnou zabavu.');
writeln ('zadejte jmeno prvniho hrace a stisknete ENTER');
readln (hrac1);
writeln ('zadejte jmeno druheho hrace a stisknete ENTER');
readln (hrac2);
writeln ('prvni hrac je tedy ', hrac1,', druhy hrac je ',hrac2);
readln;
pocet:=0;
for radek1:=1 to m do
begin
for sloupec1:=1 to n do
pole1[radek1,sloupec1]:=0;
end;
//hrac1//
writeln ('nejdrive zada souradnice ',hrac1);
while pocet<2 do
begin
writeln ('zadej prvni souradnici');
readln (radek1);
writeln ('zadej druhou souradnici');
readln (sloupec1);
if (pole1[radek1,sloupec1]=1) then
begin
writeln ('pole je obsazeno');
pocet:=pocet-1;
end;
if ((radek1>m) or (sloupec1>n) or (radek1<=0) or(sloupec1<=0)) then
begin
writeln ('souradnice jsou mimo pole');
end
else
begin
pole1[radek1,sloupec1]:=1;
pocet:=pocet+1;
end;
end;
for radek1:=1 to m do
begin
for sloupec1:=1 to n do
write (pole1[radek1,sloupec1],'-');
writeln;
end;
readln;
pocet:=0;
for radek2:=1 to m do
begin
for sloupec2:=1 to n do
pole2[radek2,sloupec2]:=0;
end;
//hrac2//
writeln ('ted zada souradnice ',hrac2);
while pocet<2 do
begin
writeln ('zadej prvni souradnici');
readln (radek2);
writeln ('zadej druhou souradnici');
readln (sloupec2);
if (pole2[radek2,sloupec2]=1) then
begin
writeln ('pole je obsazeno');
pocet:=pocet-1;
end;
if ((radek2>m) or (sloupec2>n) or (radek2<=0) or(sloupec2<=0)) then
begin
writeln ('souradnice jsou mimo pole');
end
else
begin
pole2[radek2,sloupec2]:=1;
pocet:=pocet+1;
end;
end;
for radek2:=1 to m do
begin
for sloupec2:=1 to n do
write (pole2[radek2,sloupec2],'-');
writeln;
end;
readln;
//hra//
lode1:=0;
lode2:=0;
while ((lode1<2) OR (lode2<2)) do
begin
begin
writeln ('na rade je ',hrac1);
writeln ('takto jsi strilel, 5 znamena mimo; 1 znamena zasah');
begin
for radek2palba:=1 to m do
begin
for sloupec2palba:=1 to n do
write (polepalba2[radek2palba,sloupec2palba],'-');
writeln;
end;
end;
writeln ('zadej prvni souradnici');
readln (radek2);
writeln ('zadej druhou souradnici');
readln (sloupec2);
if (pole2[radek2, sloupec2]=1) then
begin
polepalba2[radek2palba, sloupec2palba]:=1;
lode1:=lode1+1;
writeln ('zasah');
end
else
begin
lode1:=lode1+0;
writeln ('bohuzel mimo');
polepalba2[radek2palba, sloupec2palba]:=5;
end;
end;
begin
writeln ('na rade je ',hrac2);
writeln ('takto jsi strilel, 5 znamena mimo; 1 znamena zasah');
begin
for radek1palba:=1 to m do
begin
for sloupec1palba:=1 to n do
write (polepalba1[radek1palba,sloupec1palba],'-');
writeln;
end;
end;
writeln ('zadej prvni souradnici');
readln (radek1);
writeln ('zadej druhou souradnici');
readln (sloupec1);
if (pole1[radek1,sloupec1]=1) then
begin
writeln ('zasah');
lode2:=lode2+1;
polepalba1[radek1palba, sloupec1palba]:=1;
end
else
begin
writeln ('bohuzel mimo');
lode2:=lode2+0;
polepalba1[radek1palba, sloupec1palba]:=5;
end;
end;
end;
readln;
end.