Minggu, 06 Januari 2013

GAME TEBAK KATA SEPUTAR KAMPUS POLITEKNIK NEGRI TALA


uses crt;
const
havetry=10;
s: array[0..18] of string=
('fizah', 'nurul', 'pak hendrik', 'buyung', 'puput', 'politeknik', 'jurnalis',
'zakaria', 'mesin otomotif', 'tip', 'informatika', 'bu nita', 'masruroh', 'partai imm',
'tugas', 'bem poltek', 'presma', 'pak hendrik ganteng', 'ruang lab kom');
var ch: char;
gue,b,nowwrd,trynow: byte;
s1,wrs,alr: string;
r: boolean;
win: integer;
begin
win:=0;
clrscr;
writeln(' Game Tebak Kata seputar kampus politeknik negri tala');
writeln('******************************************************');
Writeln('Ketikkan huruf apa saja untuk menjawab! ESC for exit');
writeln;
randomize;
repeat
writeln;
nowwrd:=random(18);
s1:=s[nowwrd];
gue:=0;
wrs:='';
alr:='';
trynow:=havetry;
for b:=1 to length(s[nowwrd]) do write('_');
repeat
gotoxy(20,wherey);
write('You have ',trynow,' tries ');
ch:=readkey;
r:=false;
if ch<>#0 then
repeat
b:=pos(ch,s1);
if (b<>0) and (s1[b]<>#0) then
begin
gotoxy(b,wherey);
write(s1[b]);
alr:=alr+ch;
s1[b]:=#0;
gue:=gue+1;
gotoxy(40,wherey);
write(' ');
r:=true;
end else
if (pos(ch,alr)<>0) and (r=false) then
begin
gotoxy(40,wherey);
write('Already tried!');
end else
if (b=0) and (r=false) then
begin
trynow:=trynow-1;
alr:=alr+ch;
wrs:=wrs+ch;
gotoxy(57,wherey);
write('Wrong: ',wrs);
gotoxy(40,wherey);
write(' ');
end;
until (b=0) or (trynow=0);
until (ch=#27) or (gue=length(s1)) or (trynow=0);
if (trynow=0) then
begin
win:=win-1;
delline;
gotoxy(1,wherey);
write(s[nowwrd]);
gotoxy(20,wherey);
write('You lost! Your scores is ',win);
end else
if (gue=length(s1)) then
begin
win:=win+1;
delline;
gotoxy(1,wherey);
write(s[nowwrd]);
gotoxy(20,wherey);
write('You win! Your scores is ',win);
end;
until ch=#27;
end.



Tidak ada komentar:

Posting Komentar