对战小游戏
pascal吧
全部回复
仅看楼主
level 6
1308321072 楼主
program the2D_GunPlay;
uses crt;
const maxn=20;
var i,j,ch,r:integer;
HP,Power,Range,Luck,x,y:array[1..2]of integer;
Dir:array[1..2,1..2]of integer;
map:array[1..maxn,1..maxn]of integer;
b:array[1..3] of string;
function Num(peo,ee:integer; time:integer):integer;
var e:array[1..2]of integer; i1:integer;
begin
gotoxy(1,maxn+Peo*5-2);
b[1]:='';b[2]:='';b[3]:='';
if ee in[01..09] then textcolor(white);
if ee in[10..24] then textcolor(lightblue);
if ee in[25..44] then textcolor(green);
if ee in[45..70] then textcolor(magenta);
if ee in[71..99] then textcolor(brown);
e[1]:=ee mod 10;
e[2]:=ee div 10;
for i1:=2 downto 1 do
begin
if e[i1]=0 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+'|\|';
b[3]:=b[3]+'|_|'; end;
if e[i1]=1 then begin b[1]:=b[1]+' ';
b[2]:=b[2]+' | ';
b[3]:=b[3]+' | '; end;
if e[i1]=2 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+' _|';
b[3]:=b[3]+'|_ '; end;
if e[i1]=3 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+' _|';
b[3]:=b[3]+' _|'; end;
if e[i1]=4 then begin b[1]:=b[1]+' ';
b[2]:=b[2]+'|_|';
b[3]:=b[3]+' |'; end;
if e[i1]=5 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+'|_ ';
b[3]:=b[3]+' _|'; end;
if e[i1]=6 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+'|_ ';
b[3]:=b[3]+'|_|'; end;
if e[i1]=7 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+' |';
b[3]:=b[3]+' |'; end;
if e[i1]=8 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+'|_|';
b[3]:=b[3]+'|_|'; end;
if e[i1]=9 then begin b[1]:=b[1]+' _ ';
b[2]:=b[2]+'|_|';
b[3]:=b[3]+' _|'; end;
end;
writeln(b[1]);
writeln(b[2]);
writeln(b[3]);
delay(time);
exit(ee);
end;
function Diff(i1,j1,i2,j2:integer):boolean;
begin if (i1=i2)and(j1=j2) then exit(false)
else exit(true); end;
procedure show;
begin
textcolor(lightcyan); gotoxy(y[1],x[1]); writeln(chr(1));
textcolor(lightgreen); gotoxy(y[2],x[2]); writeln(chr(2));
for i:=1 to 2 do
begin
if map[x[i],y[i]]=-1 then inc(HP[i],50+trunc(random(50)));
if map[x[i],y[i]]=-2 then inc(Power[i],3+trunc(random(4)));
if map[x[i],y[i]]=-3 then inc(Range[i],1+trunc(random(2)));
if map[x[i],y[i]]=-4 then inc(Luck[i],4+trunc(random(3)));
if HP[i]>9999 then HP[i]:=9999;
if Power[i]+Luck[i]>100 then
begin Power[i]:=34; Luck[i]:=66; end;
if Range[i]>18 then Range[i]:=18;
map[x[i],y[i]]:=0;
end;
2012年11月03日 01点11分 1
level 6
1308321072 楼主
textcolor(lightcyan);
gotoxy(17,22); write(HP[1]:4);
gotoxy(17,23); write(Power[1]:4);
gotoxy(17,24); write(Range[1]:4);
gotoxy(17,25); write(Luck[1]:4);
textcolor(lightgreen);
gotoxy(17,27); write(HP[2]:4);
gotoxy(17,28); write(Power[2]:4);
gotoxy(17,29); write(Range[2]:4);
gotoxy(17,30); write(Luck[2]:4);
end;
procedure fill;
begin
randomize; clrscr; window(20,5,64,50); cursoroff;
textcolor(cyan);
writeln('开始吗?(Y/N)');
repeat
while not keypressed do;
ch:=ord(readkey);
until ch in[ord('Y'),ord('N'),ord('y'),ord('n')];
if ch in[ord('N'),ord('n')] then halt;
writeln('请稍等...');
for i:=1 to 2 do
begin
HP[i]:=1000+trunc(random(300));
Power[i]:=4+trunc(random(5));
Range[i]:=2+trunc(random(3));
Luck[i]:=6+trunc(random(2));
end;
Dir[1,1]:=1; Dir[2,1]:=-1;
x[1]:=2+trunc(random(9));
x[2]:=maxn div 2+1+trunc(random(9));
y[1]:=2+trunc(random(9));
y[2]:=maxn div 2+1+trunc(random(9));
for i:=1 to maxn do
begin
map[1,i]:=maxint; map[maxn,i]:=maxint;
map[i,1]:=maxint; map[i,maxn]:=maxint;
end;
for i:=2 to maxn-1 do
for j:=2 to maxn-1 do
if random<1/3 then
if Diff(i,j,x[1],y[1]) and Diff(i,j,x[2],y[2]) then
map[i,j]:=1+trunc(random(200)); delay(400); clrscr;
write('准备好了吗?');
while not keypressed do; clrscr;
for i:=99 downto 1 do Num(0,i,10);
clrscr;
for i:=1 to maxn do
begin
for j:=1 to maxn do
begin
if map[i,j]=maxint then textbackground(brown)
else if map[i,j]=0 then textbackground(black)
else textbackground(lightblue);
write(' ');
end;
writeln;
end;
textbackground(black);
textcolor(lightcyan);
gotoxy(1,21); for i:=1 to 5 do write('__',chr(1),'_');
gotoxy(1,22); write('[伤害]|[生命值]:',HP[1]:3);
gotoxy(7,23); write('|[攻击力]:',Power[1]:3);
gotoxy(7,24); write('|[穿透力]:',Range[1]:3);
gotoxy(7,25); write('|[幸运度]:',Luck[1]:3);
textcolor(lightgreen);
gotoxy(1,26); for i:=1 to 5 do write('__',chr(2),'_');
gotoxy(1,27); write('[伤害]|[生命值]:',HP[2]:3);
gotoxy(7,28); write('|[攻击力]:',Power[2]:3);
gotoxy(7,29); write('|[穿透力]:',Range[2]:3);
gotoxy(7,30); write('|[幸运度]:',Luck[2]:3);
end;
procedure thing(Peo,ii,jj,Pow:integer);
begin
if map[ii,jj]>0 then
begin
dec(map[ii,jj],Num(Peo,Pow,0));
if map[ii,jj]<=0 then
begin
map[ii,jj]:=0;
gotoxy(jj,ii);
if random<0.142857 then
begin
i:=1+trunc(random(11));
if i in[1..3] then
begin
map[ii,jj]:=-1;
textcolor(red);
write('H');
end;
if i in[4..6] then
begin
map[ii,jj]:=-2;
textcolor(magenta);
write('P');

2012年11月03日 01点11分 2
level 6
1308321072 楼主
end;
if i in[7..9] then
begin
map[ii,jj]:=-3;
textcolor(lightblue);
write('R');
end;
if i in[10..11] then
begin
map[ii,jj]:=-4;
textcolor(yellow);
write('L');
end;
end else write(' ');
end;
end;
for i:=1 to 2 do
if not Diff(ii,jj,x[i],y[i]) then
dec(HP[i],Num(Peo,Pow,0));
end;
procedure Launch(Peo,ii,jj,Dir1,Dir2,TheRange,ThePower:integer);
begin
r:=TheRange;
while (map[ii+Dir1,jj+Dir2]=0)and(r>0)
and(Diff(ii+Dir1,jj+Dir2,x[1],y[1]))
and(Diff(ii+Dir1,jj+Dir2,x[2],y[2])) do
begin
dec(r);
inc(ii,Dir1); inc(jj,Dir2);
gotoxy(jj,ii);
if TheRange in[01..03] then textcolor(white);
if TheRange in[04..06] then textcolor(lightblue);
if TheRange in[07..10] then textcolor(green);
if TheRange in[11..14] then textcolor(magenta);
if TheRange in[15..18] then textcolor(brown);
if ThePower in[01..09] then write('+');
if ThePower in[10..24] then write('*');
if ThePower in[25..44] then write('%');
if ThePower in[45..69] then write('@');
if ThePower in[70..99] then write('');
delay(4); gotoxy(jj,ii); write(' ');
end;
if r>0 then thing(Peo,ii+Dir1,jj+Dir2,ThePower);
end;
procedure Walk(Peo,Direc,V:integer);
begin
delay((Range[1]+Range[2])*2);
Dir[Peo,1]:=0; Dir[Peo,2]:=0;
Dir[Peo,Direc]:=V;
end;
procedure run;
begin
show;
delay(10);
if keypressed then
begin
ch:=ord(readkey);
if ch in[119,097,115,100,104] then
begin
gotoxy(y[1],x[1]); write(' ');
case ch of
119: begin Walk(1,1,-1); if map[x[1]-1,y[1]]<=0 then dec(x[1]); end;
097: begin Walk(1,2,-1); if map[x[1],y[1]-1]<=0 then dec(y[1]); end;
115: begin Walk(1,1,+1); if map[x[1]+1,y[1]]<=0 then inc(x[1]); end;
100: begin Walk(1,2,+1); if map[x[1],y[1]+1]<=0 then inc(y[1]); end;
104: Launch(1,x[1],y[1],Dir[1,1],Dir[1,2],Range[1],Power[1]+trunc(random(Luck[1])));
end;
end;
if ch in[$48,$4b,$50,$4d,046] then
begin
gotoxy(y[2],x[2]); write(' ');
case ch of
$48: begin Walk(2,1,-1); if map[x[2]-1,y[2]]<=0 then dec(x[2]); end;
$4b: begin Walk(2,2,-1); if map[x[2],y[2]-1]<=0 then dec(y[2]); end;
$50: begin Walk(2,1,+1); if map[x[2]+1,y[2]]<=0 then inc(x[2]); end;
$4d: begin Walk(2,2,+1); if map[x[2],y[2]+1]<=0 then inc(y[2]); end;
046: Launch(2,x[2],y[2],Dir[2,1],Dir[2,2],Range[2],Power[2]+trunc(random(Luck[2])));
end;
end;
end;
end;
procedure over;
begin
textcolor(lightblue);
clrscr;
if HP[1]>0 then begin textcolor(lightcyan); writeln(' __ | ');
writeln('|__| | | | _ | | _ | ');
writeln('| \ | | | /~_\ \ /\ / ( ) |\ | | ');
writeln('|__/ |/ \/ \__ \/ \/ ~ | \| * '); end;
if HP[2]>0 then begin textcolor(lightgreen); writeln(' _ |');
writeln(' / \ _ _ | | _ |');
writeln('| _ |/^ /~_\ /~_\ |\ | \ /\ / ( ) |\ | |');
writeln(' \_| | \__ \__ | \| \/ \/ ~ | \| *'); end;
delay(999);
end;
begin
fill;
while (HP[1]>0)and(HP[2]>0) do run;
over;
end.
2012年11月03日 01点11分 3
level 6
1308321072 楼主
各位大神那!怎么中文在FP里就是显示不出来了?啊啊啊!
2012年11月03日 01点11分 4
不可能啊,我的fp2.4.0可以啊
2012年11月03日 07点11分
除非你用了CRT,不过貌似在2.0.4中CRT可以(我好像试过,又好像没有)……
2012年11月03日 07点11分
有可能是我们学校的fp只有2.0.0,所以看不出来,可是我家里的2.4.4也看不出来,这是肿么回事?[汗]
2012年11月03日 08点11分
右键 属性 调回9什么什么的 就跟调437一样
2012年11月03日 15点11分
level 6
1308321072 楼主
2012年11月03日 02点11分 5
level 11
用了crt貌似就不能用中文了。。。
2012年11月03日 02点11分 6
2.0.4可以
2012年11月04日 05点11分
回复@fp4869 :我去试试。。
2012年11月04日 05点11分
回复 式圆周率 :我试过了
2012年11月04日 05点11分
回复@fp4869 :更高级的版本不行么?。
2012年11月04日 05点11分
level 11
原创吗
2012年11月03日 03点11分 7
level 6
1308321072 楼主
yes!我发的这个,还有塔防都是原创[Love]
2012年11月03日 08点11分 8
加精鼓励
2012年11月03日 10点11分
thanks!
2012年11月04日 04点11分
能不能发个连pascal的 源代码 [Yeah]复制不及去也
2012年11月04日 08点11分
level 6
1308321072 楼主
为方便大家下载,我放在网盘上了:[无效] http://pan.baidu.com/share/link?shareid=110914&uk=1158745270
2012年11月10日 04点11分 9
level 6
1308321072 楼主
密码:pascal
2012年11月10日 04点11分 10
level 14
发来发去,我TM怎么玩都不知道!
2012年11月10日 07点11分 11
level 1
窗口异常抖动
2012年11月10日 08点11分 12
level 6
1308321072 楼主
窗口异常抖动?
有可能你用的Pascal是2.4.4吧?2.4.4是不能显示这个游戏的。
2012年11月17日 00点11分 13
level 1
代码都运行不通。。。。。。。。。》》
2012年11月23日 07点11分 14
level 6
抖动的把框拉大点
2012年11月29日 14点11分 15
level 6
开始按“Y”
蓝的 WSAD对应上下左右 H攻击
绿的 方向键上下左右 .攻击
(终于弄懂了)
2012年11月29日 14点11分 16
level 5
[汗]看[汗]不[汗]懂[揉脸]
2012年12月02日 05点12分 17
level 5
小绿赢了
2012年12月04日 03点12分 18
level 4
这是……pascal?
2012年12月04日 16点12分 19
level 11
哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
2013年12月22日 06点12分 20
我都做出pascal版mc了。以后发。像泰拉瑞亚一样
2013年12月22日 09点12分
回复 IT文艺喵 :支持你
2013年12月25日 05点12分
1 2 尾页