Rating: 2.6/5 (75 votos)




Jogo Do Galo

Jogo Do Galo

program jogodogalo;
uses crt;

{definição de variaveis}

VAR nome1,nome2:string;
       i,j,k,s,f,pos:integer;
       mat:array[1..50,1..50] of string;


begin

{construção de um tabuleiro de jogo e leitura dos nomes dos jogadores}


   textcolor(white);
   writeln('JOGO DO GALO');
   writeln('');
   textcolor(lightgreen);

   write('Nome Jogador 1 : ');
   readln(nome1);
   textcolor(lightcyan);
   write('Nome Jogador 2 : ');
   readln(nome2);
   textcolor(yellow);
   gotoxy(63,23);
   write('Produzido por :');
   gotoxy(72,25);
   write('JFTS .');
   gotoxy(39,4);
   write('---+---+---');
   gotoxy(39,8);
   write('---+---+---');
   gotoxy(42,1);
   write('|');
   gotoxy(42,2);
   write('|');
   gotoxy(42,3);
   write('|');
   gotoxy(42,5);
   write('|');
   gotoxy(42,6);
   write('|');
   gotoxy(42,7);
   write('|');
   gotoxy(42,9);
   write('|');
   gotoxy(42,10);
   write('|');
   gotoxy(42,11);
   write('|');
   gotoxy(46,1);
   write('|');
   gotoxy(46,2);
   write('|');
   gotoxy(46,3);
   write('|');
   gotoxy(46,5);
   write('|');
   gotoxy(46,6);
   write('|');
   gotoxy(46,7);
   write('|');
   gotoxy(46,9);
   write('|');
   gotoxy(46,10);
   write('|');
   gotoxy(46,11);
   write('|');
   gotoxy(40,2);
   write('1');
   gotoxy(40,6);
   write('2');
   gotoxy(40,10);
   write('3');
   gotoxy(44,2);
   write('4');
   gotoxy(44,6);
   write('5');
   gotoxy(44,10);
   write('6');
   gotoxy(48,2);
   write('7');
   gotoxy(48,6);
   write('8');
   gotoxy(48,10);
   write('9');
   textcolor(white);
   gotoxy(36,13);
   write('Tabuleiro de Jogo :');
   gotoxy(39,18);
   write('---+---+---');
   gotoxy(39,22);
   write('---+---+---');
   gotoxy(42,15);
   write('|');
   gotoxy(42,16);
   write('|');
   gotoxy(42,17);
   write('|');
   gotoxy(42,19);
   write('|');
   gotoxy(42,20);
   write('|');
   gotoxy(42,21);
   write('|');
   gotoxy(42,23);
   write('|');
   gotoxy(42,24);
   write('|');
   gotoxy(42,25);
   write('|');
   gotoxy(46,15);
   write('|');
   gotoxy(46,16);
   write('|');
   gotoxy(46,17);
   write('|');
   gotoxy(46,19);
   write('|');
   gotoxy(46,20);
   write('|');
   gotoxy(46,21);
   write('|');
   gotoxy(46,23);
   write('|');
   gotoxy(46,24);
   write('|');
   gotoxy(46,25);
   write('|');

{----------------------------------}

for i:=1 to 3 do
begin
for j:=1 to 3 do mat[i,j]:='';
end;
for k:=1 to 9 do
begin
f:=0;
if (f=0)
then begin
textcolor(lightgreen);
gotoxy(1,10);
write('Vez de ',nome1,' jogar : ');
read(pos);
if (pos<1) or (pos>9)
then begin
textcolor(white);
gotoxy(1,23);
write('Posicao invalida, insira novamente');
textcolor(lightgreen);
gotoxy(1,10);
write('Vez de ',nome1,' jogar : ');
read(pos);
end;
if (pos=1)
then begin
gotoxy(40,16);
write('X');
i:=1;
j:=1;
end;
if (pos=2)
then begin
i:=2;
j:=1;
gotoxy(40,20);
write('X');
end;
if (pos=3)
then begin
i:=3;
j:=1;
gotoxy(40,24);
write('X');
end;
if (pos=4)
then begin
i:=1;
j:=2;
gotoxy(44,16);
write('X');
end;
if (pos=5)
then begin
i:=2;
j:=2;
gotoxy(44,20);
write('X');
end;
if (pos=6)
then begin
i:=3;
j:=2;
gotoxy(44,24);
write('X');
end;
if (pos=7)
then begin
i:=1;
j:=3;
gotoxy(48,16);
write('X');
end;
if (pos=8)
then begin
i:=2;
j:=3;
gotoxy(48,20);
write('X');
end;
if (pos=9)
then begin
i:=3;
j:=3;
gotoxy(48,24);
write('X');
end;
mat[i,j]:='X';

{------------------------------------}

textcolor(brown);
if (mat[1,2]='X') and (mat[1,1]='X') and (mat[1,3]='X')
then begin
gotoxy(1,30);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[2,2]='X') and (mat[2,1]='X') and (mat[2,3]='X')
then begin
gotoxy(1,30);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[3,2]='X') and (mat[3,1]='X') and (mat[3,3]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[1,1]='X') and (mat[2,1]='X') and (mat[3,1]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[1,2]='X') and (mat[2,2]='X') and (mat[3,2]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[1,3]='X') and (mat[2,3]='X') and (mat[3,3]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[1,1]='X') and (mat[2,2]='X') and (mat[3,3]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (mat[2,2]='X') and (mat[3,1]='X') and (mat[1,3]='X')
then begin
gotoxy(1,25);
write('VENCEDOR: ',nome1);
s:=1;
k:=9;
end;
if (s=1)
then begin
delay(3000);
exit;
end;


{-------------------------------}

f:=1;
if (f=1)
then begin
textcolor(lightcyan);
gotoxy(1,12);
write('Vez de ',nome2,' jogar : ');
read(pos);
if (pos<1) or (pos>9)
then begin
textcolor(white);
gotoxy(1,23);
write('Posicao invalida, insira novamente');
textcolor(lightcyan);
gotoxy(1,12);
write('Vez de ',nome2,' jogar : ');
read(pos);
end;
if (pos=1)
then begin
gotoxy(40,16);
write('0');
i:=1;
j:=1;
end;
if (pos=2)
then begin
i:=2;
j:=1;
gotoxy(40,20);
write('0');
end;
if (pos=3)
then begin
i:=3;
j:=1;
gotoxy(40,24);
write('0');
end;
if (pos=4)
then begin
i:=1;
j:=2;
gotoxy(44,16);
write('0');
end;
if (pos=5)
then begin
i:=2;
j:=2;
gotoxy(44,20);
write('0');
end;
if (pos=6)
then begin
i:=3;
j:=2;
gotoxy(44,24);
write('0');
end;
if (pos=7)
then begin
i:=1;
j:=3;
gotoxy(48,16);
write('0');
end;
if (pos=8)
then begin
i:=2;
j:=3;
gotoxy(48,20);
write('0');
end;
if (pos=9)
then begin
i:=3;
j:=3;
gotoxy(48,24);
write('0');
end;
mat[i,j]:='0';
end;
end;

{-------------------------------}

textcolor(yellow);
if (mat[1,2]='0') and (mat[1,1]='0') and (mat[1,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[2,2]='0') and (mat[2,1]='0') and (mat[2,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[3,2]='0') and (mat[3,1]='0') and (mat[3,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[1,1]='0') and (mat[2,1]='0') and (mat[3,1]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[1,2]='0') and (mat[2,2]='0') and (mat[3,2]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[1,3]='0') and (mat[2,3]='0') and (mat[3,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[1,1]='0') and (mat[2,2]='0') and (mat[3,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (mat[2,2]='0') and (mat[3,1]='0') and (mat[1,3]='0')
then begin
gotoxy(1,25);
write('Vencedor: ',nome2);
s:=1;
k:=9;
end;
if (s=1)
then begin
delay(3000);
exit;
end;

end;

{------------------------------------}

if (s<>1)
then begin
textcolor(yellow);
gotoxy(1,30);
write('Empate');
delay(3000);
exit;
end;
end.