主题:[原创]各位大虾,帮我修改一下
program L_snack_011;
uses crt;
type
d=array [1..20,1..50] of char;
e=array [1..250] of integer;
var
a:d;
b,c:e;
mark,l1,l2,l3,l4,l5,r1,r2,i,j,f,k,l,m,n:integer;
cc,ch:char;
procedure print(a:d;
i,j:integer);
begin
clrscr;
for i:=1 to 20 do
begin
for j:=1 to 50 do
write(a[i,j]);
writeln;
end;
end;
procedure print1(a:d;
i,j:integer);
begin
for i:=2 to 19 do
begin
gotoxy(2,i);
for j:=2 to 43 do
write(a[i,j]);
end;
end;
begin
for i:=2 to 19 do
begin
a[i,1]:='I';
a[i,44]:='I';
a[i,50]:='I';
end;
for j:=1 to 50 do
begin
a[1,j]:='=';
a[20,j]:='=';
end;
for i:=45 to 49 do
a[10,i]:='=';
l:=0;
f:=5;
for j:=6 downto 2 do
begin
l:=l+1;
b[l]:=2;
c[l]:=j;
a[b[l],c[l]]:='*';
end;
randomize;
repeat
r1:=random(41)+2;
r2:=random(17)+2;
for i:=1 to f do
if (r1=c[i]) and (r2=b[i]) then
begin
cc:='c';
break;
end
else cc:='s';
until cc='s';
a[r2,r1]:='$';
print(a,i,j);
a[b[1],c[1]]:=' ';
repeat
until keypressed;
while (a[b[1],c[1]]<>'=') and (a[b[1],c[1]]<>'I') and (a[b[1],c[1]]<>'*')
do
begin
for i:=1 to f do
a[b[i],c[i]]:='*';
m:=b[1]-b[2];
n:=c[1]-c[2];
print1(a,i,j);
mark:=(f-5)*100;
gotoxy(45,7);
write('分数':4);
gotoxy(45,9);
write(mark:4);
a[b[f],c[f]]:=' ';
b[f+1]:=b[f];
c[f+1]:=c[f];
for i:=f downto 2 do
begin
b[i]:=b[i-1];
c[i]:=c[i-1];
end;
delay(200);
if keypressed then
ch:=readkey;
case ord(ch) of
$48:b[1]:=b[1]-1;
$50:b[1]:=b[1]+1;
$4b:c[1]:=c[1]-1;
$4d:c[1]:=c[1]+1;
else
begin
if m<>0 then if m>0 then b[1]:=b[1]+1
else b[1]:=b[1]-1
else if n>0 then c[1]:=c[1]+1
else c[1]:=c[1]-1;
end;
end;
if (b[1]=b[3]) and (c[1]=c[3]) then
begin
b[1]:=b[2];
c[1]:=c[2];
if m<>0 then if m>0 then b[1]:=b[1]+1
else b[1]:=b[1]-1
else if n>0 then c[1]:=c[1]+1
else c[1]:=c[1]-1;
end;
if a[b[1],c[1]]='$' then
begin
Sound(220); { Beep }
Delay(200); { For 200 ms }
NoSound; { Relief! }
f:=f+1;
repeat
r1:=random(41)+2;
r2:=random(17)+2;
for i:=1 to f do
if (r1=c[i]) and (r2=b[i]) then
begin
cc:='c';
break;
end
else cc:='s';
until cc='s';
a[r2,r1]:='$';
end;
end;
for i:=1 to 3 do
begin
Sound(440); { Beep }
Delay(300); { For 200 ms }
NoSound; { Relief! }
Sound(190); { Beep }
Delay(300); { For 200 ms }
NoSound; { Relief! }
end;
end.
请帮我增加以下几点:
1.有生命值
2.可随意设置宽度和大小
3.可随意设置蛇的长度
uses crt;
type
d=array [1..20,1..50] of char;
e=array [1..250] of integer;
var
a:d;
b,c:e;
mark,l1,l2,l3,l4,l5,r1,r2,i,j,f,k,l,m,n:integer;
cc,ch:char;
procedure print(a:d;
i,j:integer);
begin
clrscr;
for i:=1 to 20 do
begin
for j:=1 to 50 do
write(a[i,j]);
writeln;
end;
end;
procedure print1(a:d;
i,j:integer);
begin
for i:=2 to 19 do
begin
gotoxy(2,i);
for j:=2 to 43 do
write(a[i,j]);
end;
end;
begin
for i:=2 to 19 do
begin
a[i,1]:='I';
a[i,44]:='I';
a[i,50]:='I';
end;
for j:=1 to 50 do
begin
a[1,j]:='=';
a[20,j]:='=';
end;
for i:=45 to 49 do
a[10,i]:='=';
l:=0;
f:=5;
for j:=6 downto 2 do
begin
l:=l+1;
b[l]:=2;
c[l]:=j;
a[b[l],c[l]]:='*';
end;
randomize;
repeat
r1:=random(41)+2;
r2:=random(17)+2;
for i:=1 to f do
if (r1=c[i]) and (r2=b[i]) then
begin
cc:='c';
break;
end
else cc:='s';
until cc='s';
a[r2,r1]:='$';
print(a,i,j);
a[b[1],c[1]]:=' ';
repeat
until keypressed;
while (a[b[1],c[1]]<>'=') and (a[b[1],c[1]]<>'I') and (a[b[1],c[1]]<>'*')
do
begin
for i:=1 to f do
a[b[i],c[i]]:='*';
m:=b[1]-b[2];
n:=c[1]-c[2];
print1(a,i,j);
mark:=(f-5)*100;
gotoxy(45,7);
write('分数':4);
gotoxy(45,9);
write(mark:4);
a[b[f],c[f]]:=' ';
b[f+1]:=b[f];
c[f+1]:=c[f];
for i:=f downto 2 do
begin
b[i]:=b[i-1];
c[i]:=c[i-1];
end;
delay(200);
if keypressed then
ch:=readkey;
case ord(ch) of
$48:b[1]:=b[1]-1;
$50:b[1]:=b[1]+1;
$4b:c[1]:=c[1]-1;
$4d:c[1]:=c[1]+1;
else
begin
if m<>0 then if m>0 then b[1]:=b[1]+1
else b[1]:=b[1]-1
else if n>0 then c[1]:=c[1]+1
else c[1]:=c[1]-1;
end;
end;
if (b[1]=b[3]) and (c[1]=c[3]) then
begin
b[1]:=b[2];
c[1]:=c[2];
if m<>0 then if m>0 then b[1]:=b[1]+1
else b[1]:=b[1]-1
else if n>0 then c[1]:=c[1]+1
else c[1]:=c[1]-1;
end;
if a[b[1],c[1]]='$' then
begin
Sound(220); { Beep }
Delay(200); { For 200 ms }
NoSound; { Relief! }
f:=f+1;
repeat
r1:=random(41)+2;
r2:=random(17)+2;
for i:=1 to f do
if (r1=c[i]) and (r2=b[i]) then
begin
cc:='c';
break;
end
else cc:='s';
until cc='s';
a[r2,r1]:='$';
end;
end;
for i:=1 to 3 do
begin
Sound(440); { Beep }
Delay(300); { For 200 ms }
NoSound; { Relief! }
Sound(190); { Beep }
Delay(300); { For 200 ms }
NoSound; { Relief! }
end;
end.
请帮我增加以下几点:
1.有生命值
2.可随意设置宽度和大小
3.可随意设置蛇的长度