第4个回答 2012-03-03
不要换,fp也有它的乐趣 你可以试着编个小游戏玩玩 给你看一个 fp能存在这么久 肯定有它的理由
uses crt;
const x=12;
var p:array[1..x,1..x] of string;
t:array[1..x,1..x] of boolean;
i,k,j,n,l,s,a,b,c,d,e,f,g,h,a1,a2,a3,a4,a5,a6,a7,a8,e3,a9,a10,shu,yin,v,w,ss,as,q12,pp,we,zet,vt:longint;
z:char;
q,doy:string;
vv:string;
b1,b2:boolean;
begin
vt:=1;
writeln('Welcome to <eat been> game');
readln;
writeln('How to play:');
writeln(' Do not go the same way(the starts means that you can''t go)');
writeln;
readln;
writeln(' w up');
writeln('a s d left down right');
writeln;
readln;
writeln('jump to the second place,and ''ss'' must>0');
writeln('(every 20 walks can make one''ss'',and every level will be higher)');
writeln(' i up');
writeln('j k l left down right ');
writeln;
readln;
writeln('p It means:I think I lose,and I want to go out');
readln;
writeln('There are 5 levels at all');
readln;
ss:=1;
l:=1;
we:=20;
repeat
begin
if l=6 then break;
if zet=1 then break;
//输入棋盘
gotoxy(1,1);
ClrScr;
Clreol;
shu:=0;
yin:=0;
gotoxy(1,1);
textbackground(green);
for i:=1 to 80 do
begin
for j:=1 to 15 do
write(' ');
writeln;
end;
gotoxy(1,1);
ClrScr;
Clreol;
if l=5 then
begin
for i:=1 to 10 do writeln;
for i:=1 to 30 do write(' ');
write('Level:',l,'(BOSS)');
delay(1200);
end;
ClrScr;
Clreol;
if l<>5 then
begin
for i:=1 to 10 do writeln;
for i:=1 to 35 do write(' ');
write('Level:',l);
delay(1200);
end;
gotoxy(1,1);
for i:=1 to x do
for j:=1 to x do p[i,j]:='. ';
randomize;
a1:=random(x-3);
a2:=random(x-2);
p[a1,a2]:='* ';
a3:=random(x-5);
a4:=random(x-4);
p[a3,a4]:='* ';
for i:=1 to x do
for j:=1 to x do
t[i,j]:=TRUE;
for i:=1 to x do
begin
t[1,i]:=FALSE;
t[i,1]:=FALSE;
t[x,i]:=FALSE;
t[i,x]:=FALSE;
p[1,i]:='__';
p[i,1]:=' |';
p[x,i]:='--';
p[i,x]:='| ';
end;
p[1,x]:=' ';
p[1,1]:=' ';
p[x,1]:=' ';
p[x,x]:=' ';
t[a1,a2]:=FALSE;
t[a3,a4]:=FALSE;
if l>2 then
begin
t[6,5]:=FALSE;
p[6,5]:='* ';
t[7,2]:=FALSE;
p[7,2]:='* ';
end;
if l>1 then
begin
p[4,9]:='* ';
t[4,9]:=FALSE;
end;
if l>3 then
begin
p[5,10]:='* ';
t[5,10]:=FALSE;
t[2,9]:=FALSE;
p[2,9]:='* ';
t[7,6]:=FALSE;
p[7,6]:='* ';
end;
if l>4 then
begin
we:=we+6;
t[3,2]:=FALSE;
p[3,2]:='* ';
t[4,2]:=FALSE;
p[4,2]:='* ';
t[6,4]:=FALSE;
p[6,4]:='* ';
t[10,8]:=FALSE;
p[10,8]:='* ';
t[8,8]:=FALSE;
p[8,8]:='* ';
end;
randomize;
a:=random(x-2); b:=random(x-2);
a:=a+2;
b:=b+2;
p[a,b]:='0 ';
t[a,b]:=FALSE;
repeat
begin
for v:=1 to x do
begin
for j:=1 to x do write(p[v,j]);
writeln;
end;
gotoxy(38,2);
write('Level:',l);
if l=5 then writeln('(BOSS)');
gotoxy(38,3);
writeln('ss:=',ss);
gotoxy(38,4);
writeln('walks:=',as,'/',we);
gotoxy(1,1);
while not keypressed do;
z:=readkey;
writeln(z);
if (z='w') and (a-1>0) and (t[a-1,b]=TRUE) then
begin
p[a,b]:='* ';
a:=a-1;
p[a,b]:='0 ';
t[a,b]:=FALSE;
pp:=pp+1;
end;
if (z='a') and (b-1>0) and (t[a,b-1]=TRUE) then
begin
p[a,b]:='* ';
b:=b-1;
p[a,b]:='0 ';
t[a,b]:=FALSE;
pp:=pp+1;
end;
if (z='s') and (a+1<x+1) and (t[a+1,b]=TRUE)then
begin
p[a,b]:='* ';
a:=a+1;
p[a,b]:='0 ';
t[a,b]:=FALSE;
pp:=pp+1;
end;
if (z='d') and (b+1<x+1) and (t[a,b+1]=TRUE)then
begin
p[a,b]:='* ';
b:=b+1;
p[a,b]:='0 ';
t[a,b]:=FALSE;
pp:=pp+1;
end;
if z='p' then
begin
ClrScr;
Clreol;
writeln('Do you want to go out?(Y/N or YES/NO)');
readln(vv);
if (vv='Y') or (vv='y') or (vv='YES') or (vv='yes') or (vv='Yes') then
begin
shu:=shu+1;
zet:=1;
break;
end
else
begin
writeln('Go on!');
readln;
end;
end;
if (z='i') and (a-2>0) and (t[a-2,b]=TRUE) and (ss>0) then
begin
p[a,b]:='* ';
a:=a-2;
p[a,b]:='0 ';
t[a,b]:=FALSE;
ss:=ss-1;
end;
if (z='j') and (b-2>0) and (t[a,b-2]=TRUE) and (ss>0)then
begin
p[a,b]:='* ';
b:=b-2;
p[a,b]:='0 ';
t[a,b]:=FALSE;
ss:=ss-1;
end;
if (z='k') and (a+2<x+1) and (t[a+2,b]=TRUE) and (ss>0)then
begin
p[a,b]:='* ';
a:=a+2;
p[a,b]:='0 ';
t[a,b]:=FALSE;
ss:=ss-1;
end;
if (z='l') and (b+2<x+1) and (t[a,b+2]=TRUE) and (ss>0)then
begin
p[a,b]:='* ';
b:=b+2;
p[a,b]:='0 ';
t[a,b]:=FALSE;
ss:=ss-1;
end;
for v:=1 to x do
begin
for j:=1 to x do write(p[v,j]);
writeln;
end;
end;
w:=0;
//判断赢了;
for i:=2 to x-1 do
for j:=2 to x-1 do
begin
if t[i,j]=FALSE then w:=w+1;
end;
if w=(x-2)*(x-2) then
begin
sound(200);
ClrScr;
Clreol;
for i:=1 to 10 do writeln;
for i:=1 to 34 do write(' ');
writeln('You win!');
yin:=yin+1;
doy:='y';
l:=l+1;
we:=we+3;
e3:=1;
delay(800);
break;
end;
//判断输了;
if (t[a+2,b]=FALSE) and (t[a-2,b]=FALSE) and (t[a,b+2]=FALSE) and (t[a,b-2]=FALSE) and (t[a+1,b]=FALSE) and (t[a-1,b]=FALSE) and (t[a,b-1]=FALSE) and (t[a,b+1]=FALSE) then
begin
sound(200);
delay(800);
ClrScr;
Clreol;
for i:=1 to 10 do writeln;
for i:=1 to 34 do write(' ');
writeln('GAME OVER!');
shu:=shu+1;
doy:='s';
delay(800);
break;
end;
if (t[a+1,b]=FALSE) and (t[a-1,b]=FALSE) and (t[a,b-1]=FALSE) and (t[a,b+1]=FALSE) and (e3<>1) and (ss=0) then
begin
sound(200);
delay(800);
ClrScr;
Clreol;
for i:=1 to 10 do writeln;
for i:=1 to 34 do write(' ');
writeln('GAME OVER!');
shu:=shu+1;
doy:='s';
delay(800);
break;
end;
e3:=0;
if pp=1 then as:=as+1;
pp:=0;
if as=we then
begin
ss:=ss+1;
as:=0;
end;
ClrScr;
Clreol;
if zet=1 then break;
until 1+1<2;
if doy='y' then vt:=ss;
ClrScr;
Clreol;
if doy='s' then
begin
textbackground(black);
for i:=1 to 40 do
begin
for j:=1 to 20 do write(' ');
writeln;
end;
ClrScr;
writeln('Do you want to try again?(Y/N or YES/NO,small words is OK)');
readln(q);
if (q='Y') or (q='YES') or (q='y') or (q='yes') or (q='Yes')then
begin
writeln('OK!Try again!');
delay(800);
sound(200);
end;
if (q='N') or (q='NO') or (q='n') or (q='no') or (q='No')then break;
end;
doy:='';
textbackground(green);
ss:=vt;
end;
until 1+1<2;
ClrScr;
Clreol;
if l=6 then writeln('What a good boy!!You win the game!!!') else
begin
writeln('You win ',yin,' times,lose ',shu,' times.');
if yin<shu then writeln('What a pig!');
if yin=shu then writeln('Pig!');
if shu<yin then writeln('pig!!!!');
end;
readln;
end.