Membuat Games Dengan Program Turbo Pascal 7.0

Ini salah satu Permaianan Denga Pemrograman Turbo Pascal 7.0
uses crt;
const
havetry=10;
s: array[0..18] of string=
(‘hello’, ‘mouse’, ‘hacher’, ‘programmer’, ‘killer’, ‘teacher’, ‘splotchier’,
‘butcher’, ‘computer’, ‘pascal’, ‘house’, ‘poor’, ‘children’, ‘museum’,
‘security’, ‘spillway’, ‘stupidity’, ‘corrigenda’, ‘freebooter’);
var ch: char;
gue,b,nowwrd,trynow: byte;
s1,wrs,alr: string;
r: boolean;
win: integer;
begin
win:=0;
clrscr;
writeln(‘Game Tebak Kata’);
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 (b0) 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.
Dan ini gambar dari contoh program di atas

untuk lebih jelas klik Gambar di atas….
Silahkan mencoba dan Copy Paste aja neh Programnya ^^

0 komentar:

 
Top