Fala galera!
sou novo em programação, comecei a estudar a 1 semana .
tava treinando PASCAL ontem, e tentei fazer um joguinho da forca...
o jogo funcionou tranquilo, mas quando inclui umas funções nele, entrou num loop infinito, e nao estou conseguindo identificar...
toda a parte do jogo em si estava funcionando perfeitamente.
o que eu inseri depois (e começou o problema) foi uma tela inicial de apresentação do jogo, e uma flag pra quando terminar o programa, ele perguntar se quer iniciar novamente...
pronto..depois disso o programa ficou maluco!
queria a ajuda de vocês pra achar o erro na programação!
fiz o codigo em FPC (nao sei se isso faz alguma diferença)
valeu galera! obrigado!
abaixo está o codigo do programa...
sou novo em programação, comecei a estudar a 1 semana .
tava treinando PASCAL ontem, e tentei fazer um joguinho da forca...
o jogo funcionou tranquilo, mas quando inclui umas funções nele, entrou num loop infinito, e nao estou conseguindo identificar...
toda a parte do jogo em si estava funcionando perfeitamente.
o que eu inseri depois (e começou o problema) foi uma tela inicial de apresentação do jogo, e uma flag pra quando terminar o programa, ele perguntar se quer iniciar novamente...
pronto..depois disso o programa ficou maluco!
queria a ajuda de vocês pra achar o erro na programação!
fiz o codigo em FPC (nao sei se isso faz alguma diferença)
valeu galera! obrigado!
abaixo está o codigo do programa...
Código:
PROGRAM FORCA; uses crt; var n, i, POSICAO, ERROS,ACERTOS,spc,inicio,nivel: integer; senha,letra,FLAG: string; begin clrscr; writeln(''); writeln('-----------------------'); writeln('| |'); writeln('| |'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('----|'); gotoxy(20,5); write('======='); gotoxy(20,6); write('[ ]'); gotoxy(20,7); write('[ ]'); gotoxy(20,8); write('[ ]'); gotoxy(20,9); write('[ ]'); gotoxy(20,10); write('========'); gotoxy(23,11); write('||'); gotoxy(23,12); write('||'); gotoxy(23,13); write('||'); gotoxy(23,14); write('||'); gotoxy(23,15); write('||'); gotoxy(23,16); write('||'); gotoxy(24,16); write('||'); gotoxy(25,17); write('||'); gotoxy(26,18); write('||'); gotoxy(22,16); write('||'); gotoxy(21,17); write('||'); gotoxy(20,18); write('||'); gotoxy(22,13); write('||'); gotoxy(21,13); write('||'); gotoxy(20,13); write('||'); gotoxy(24,13); write('||'); gotoxy(25,13); write('||'); gotoxy(26,13); write('||'); gotoxy(25,7); write('+'); gotoxy(22,7); write('+'); gotoxy(22,9); write('----'); gotoxy(35,15); writeln('BEM VINDO AO JOGO DA FORCA!'); gotoxy(35,16); writeln('CRIADO EM DESENVOLVIDO POR TULIO GUIMARÇES'); gotoxy(35,18); write('ESCOLHA O NIVEL: '); gotoxy(35,19); write('1 - FACIL (10 CHANCES)'); gotoxy(35,20); write('2 - MEDIO (7 CHANCES)'); gotoxy(35,21); write('3 - DIFICIL (5 CHANCES)'); read(nivel); case nivel of 1: nivel:= 10; 2: nivel:= 7; 3: nivel:= 5; end; clrscr; writeln(''); writeln('-----------------------'); writeln('| |'); writeln('| |'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('|'); writeln('----|'); readkey; writeln('digite a palavra : '); read(senha); n:= length(senha); i:=0; clrscr; gotoxy(20,20); repeat write('_ '); i:= i + 1; until i = n; i:=1; writeln(' '); writeln(' '); ACERTOS:=0; ERROS:=-1; gotoxy(20,22); write('digite uma letra : '); spc:= 1; while (ACERTOS <> n) and (ACERTOS <>'999') do begin gotoxy(50,15); writeln('VOCE AINDA TEM ',nivel-ERROS, ' CHANCES'); gotoxy(50,20); writeln('LETRAS ERRADAS ( ',ERROS, ' )'); gotoxy(20+ spc,23); readln(letra); spc:= spc+2; inicio:= 1; if pos(letra,senha)=0 then begin ERROS:=ERROS + 1; gotoxy(45+spc,21); write(letra); end; if nivel = 5 then begin if ERROS = 1 then begin gotoxy(20,5); write('======='); gotoxy(20,6); write('[ ]'); gotoxy(20,7); write('[ ]'); gotoxy(20,8); write('[ ]'); gotoxy(20,9); write('[ ]'); gotoxy(20,10); write('========'); end; if ERROS = 2 then begin gotoxy(23,11); write('||'); gotoxy(23,12); write('||'); gotoxy(23,13); write('||'); gotoxy(23,14); write('||'); gotoxy(23,15); write('||'); gotoxy(23,16); write('||'); end; if ERROS = 3 then begin gotoxy(24,16); write('||'); gotoxy(25,17); write('||'); gotoxy(26,18); write('||'); gotoxy(22,16); write('||'); gotoxy(21,17); write('||'); gotoxy(20,18); write('||'); end; if ERROS = 4 then begin gotoxy(22,13); write('||'); gotoxy(21,13); write('||'); gotoxy(20,13); write('||'); gotoxy(24,13); write('||'); gotoxy(25,13); write('||'); gotoxy(26,13); write('||'); end; if ERROS = 5 then begin gotoxy(25,7); write('+'); gotoxy(22,7); write('+'); gotoxy(22,9); write('----'); gotoxy(45,10); write('VOCÒ PERDEU!!!!'); readkey; ACERTOS:= 999; end; end; if nivel = 7 then begin if ERROS = 1 then begin gotoxy(20,5); write('======='); gotoxy(20,6); write('[ ]'); gotoxy(20,7); write('[ ]'); gotoxy(20,8); write('[ ]'); gotoxy(20,9); write('[ ]'); gotoxy(20,10); write('========'); end; if ERROS = 2 then begin gotoxy(23,11); write('||'); gotoxy(23,12); write('||'); gotoxy(23,13); write('||'); gotoxy(23,14); write('||'); gotoxy(23,15); write('||'); gotoxy(23,16); write('||'); end; if ERROS = 3 then begin gotoxy(24,16); write('||'); gotoxy(25,17); write('||'); gotoxy(26,18); write('||'); end; if ERROS = 4 then gotoxy(22,16); write('||'); gotoxy(21,17); write('||'); gotoxy(20,18); write('||'); end; if ERROS = 5 then begin gotoxy(22,13); write('||'); gotoxy(21,13); write('||'); gotoxy(20,13); write('||'); end; if ERROS = 6 then begin gotoxy(24,13); write('||'); gotoxy(25,13); write('||'); gotoxy(26,13); write('||'); end; if ERROS = 7 then begin gotoxy(25,7); write('+'); gotoxy(22,7); write('+'); gotoxy(22,9); write('----'); gotoxy(45,10); write('VOCÒ PERDEU!!!!'); readkey; ACERTOS:= 999; end; end; if nivel = 10 then begin if ERROS = 1 then begin gotoxy(20,5); write('======='); gotoxy(20,6); write('[ ]'); gotoxy(20,7); write('[ ]'); gotoxy(20,8); write('[ ]'); gotoxy(20,9); write('[ ]'); gotoxy(20,10); write('========'); end; if ERROS = 2 then begin gotoxy(23,11); write('||'); gotoxy(23,12); write('||'); gotoxy(23,13); end; if ERROS = 3 then begin gotoxy(22,13); write('||'); gotoxy(21,13); write('||'); gotoxy(20,13); write('||'); end; if ERROS = 4 then begin gotoxy(24,13); write('||'); gotoxy(25,13); write('||'); gotoxy(26,13); write('||'); end; if ERROS = 5 then begin write('||'); gotoxy(23,14); write('||'); gotoxy(23,15); write('||'); gotoxy(23,16); write('||'); end; if ERROS = 6 then begin gotoxy(24,16); write('||'); gotoxy(25,17); write('||'); gotoxy(26,18); write('||'); end; if ERROS = 7 then begin gotoxy(22,16); write('||'); gotoxy(21,17); write('||'); gotoxy(20,18); write('||'); end; if ERROS = 8 then begin gotoxy(25,7); write('+'); end; if ERROS = 9 then begin gotoxy(22,7); write('+'); end; if ERROS = 10 then begin gotoxy(22,9); write('----'); gotoxy(45,10); write('VOCÒ PERDEU!!!!'); readkey; ACERTOS:= 999; end; end; if pos(letra,senha) > 0 then begin for i:= inicio to n do if letra = senha[i] then begin POSICAO:= i; gotoxy(19+posicao*2-1,20); write(letra); ACERTOS:= ACERTOS + 1; inicio:= inicio + 1; end; end; if ACERTOS = n then begin clrscr; gotoxy(15,20); writeln('PARABNS, VOCÒ VENCEU!!!!'); writeln('JOGAR DE NOVO? S - Sim / N - NÆo'); read(flag); end; if ACERTOS = 999 then begin clrscr; write('TENTAR DE NOVO? S - Sim / N - NÆo'); read(flag); ACERTOS:=0; ERROS:=-1; I:=0; end; readkey; end.
Comment