用pascal怎么做游戏啊 5
展开全部
先送你一个猜数游戏:
program c_k;
var a,b,c:integer;
begin
randomize;
a:=random(100);
c:=0;
repeat
c:=c+1;
write('please input b:');
readln(b);
if b>a then writeln('Too big')
else if b<a then writeln('Too small')
else if b=a tehn writeln('you are right');
until (c=10) or (a=b);
if c=10 then writeln('you false,the number is:',a);
readln;readln;
end.
再送你一个坦克大战程序:
program tanke;
uses crt,graph;
type
type1=record
h,l,f:integer;
end;
time=record
ms,s,m:integer;
end;
const fx:array[1..4,1..2] of -1..1=((-1,0),(0,-1),(1,0),(0,1));
var t:time;
tank:type1;
bomb:array[1..20]of type1;
diren:array[1..8]of type1;
fire:array[1..20]of type1;
u,d,l,r,gu,gd,gl,gr:char;
lf:boolean;
procedure initg;
var gd,gm:integer;
begin
gd:=detect;
initgraph(gd,gm,'');
end;
procedure pushtype1(l,h,f:integer;var a:array of type1);
var i:integer;
begin
for i:=1 to high(a) do
if a[i].f<=0 then
begin
a[i].h:=h;a[i].l:=l;a[i].f:=f;
exit;
end;
end;
procedure print;
var i,j:integer;
begin
setfillstyle(white,1);
bar(0,0,600,400);
for i:=1 to high(fire) do
with fire[i] do
if f>0 then
begin
setcolor(red);
line(l*40-20,h*40-20,l*40-1,h*40-1);
line(l*40-20,h*40-20,l*40-1,h*40-10);
line(l*40-20,h*40-20,l*40-1,h*40-20);
line(l*40-20,h*40-20,l*40-1,h*40-30);
line(l*40-20,h*40-20,l*40-1,h*40-40);
line(l*40-20,h*40-20,l*40-40,h*40-1);
line(l*40-20,h*40-20,l*40-40,h*40-10);
line(l*40-20,h*40-20,l*40-40,h*40-20);
line(l*40-20,h*40-20,l*40-40,h*40-30);
line(l*40-20,h*40-20,l*40-40,h*40-40);
line(l*40-20,h*40-20,l*40-20,h*40-1);
line(l*40-20,h*40-20,l*40-30,h*40-1);
line(l*40-20,h*40-20,l*40-10,h*40-40);
line(l*40-20,h*40-20,l*40-10,h*40-1);
line(l*40-20,h*40-20,l*40-20,h*40-40);
line(l*40-20,h*40-20,l*40-30,h*40-40);
end;
for i:=1 to high(bomb) do
with bomb[i] do
if f>0 then
begin
setcolor(blue);
circle((l-1)*40+20,(h-1)*40+20,5);
end;
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
setcolor(11);
line((l-1)*40+5,(h-1)*40+1,(l-1)*40+15,(h-1)*40+10);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+10,(h-1)*40+15);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+1,(h-1)*40+5);
line((l-1)*40+1,(h-1)*40+5,(l-1)*40+5,(h-1)*40+1);
line((l-1)*40+35,(h-1)*40+1,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+25,(h-1)*40+10,(l-1)*40+30,(h-1)*40+15);
line((l-1)*40+30,(h-1)*40+15,(l-1)*40+40,(h-1)*40+5);
line((l-1)*40+40,(h-1)*40+5,(l-1)*40+35,(h-1)*40+1);
line((l-1)*40+5,(h-1)*40+40,(l-1)*40+15,(h-1)*40+30);
line((l-1)*40+15,(h-1)*40+30,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+10,(h-1)*40+25,(l-1)*40+1,(h-1)*40+35);
line((l-1)*40+1,(h-1)*40+35,(l-1)*40+5,(h-1)*40+40);
line((l-1)*40+35,(h-1)*40+40,(l-1)*40+25,(h-1)*40+30);
line((l-1)*40+25,(h-1)*40+30,(l-1)*40+30,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+40,(h-1)*40+35);
line((l-1)*40+40,(h-1)*40+35,(l-1)*40+35,(h-1)*40+40);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+15,(l-1)*40+30,(h-1)*40+25);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+15,(h-1)*40+25);
line((l-1)*40+15,(h-1)*40+30,(l-1)*40+25,(h-1)*40+30);
setcolor(red);
circle((l-1)*40+20,(h-1)*40+20,6);
end;
with tank do
begin
if f>0 then setcolor(green)
else setcolor(red);
case f of
0,1:begin
setcolor(green);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+1,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+10,(h-1)*40+10);
line((l-1)*40+1,(h-1)*40+40,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+30,(h-1)*40+40);
line((l-1)*40+40,(h-1)*40+10,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+30,(h-1)*40+15);
line((l-1)*40+10,(h-1)*40+35,(l-1)*40+30,(h-1)*40+35);
line((l-1)*40+1,(h-1)*40+20,(l-1)*40+10,(h-1)*40+20);
line((l-1)*40+1,(h-1)*40+30,(l-1)*40+10,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+20,(l-1)*40+40,(h-1)*40+20);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+40,(h-1)*40+30);
line((l-1)*40+15,(h-1)*40+1,(l-1)*40+25,(h-1)*40+1);
line((l-1)*40+15,(h-1)*40+1,(l-1)*40+15,(h-1)*40+15);
line((l-1)*40+25,(h-1)*40+1,(l-1)*40+25,(h-1)*40+15);
circle((l-1)*40+20,(h-1)*40+25,5);
end;
2:begin
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+40,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+10,(h-1)*40+10);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+40,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+40,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+15,(h-1)*40+30);
line((l-1)*40+35,(h-1)*40+10,(l-1)*40+35,(h-1)*40+30);
line((l-1)*40+20,(h-1)*40+1,(l-1)*40+20,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+1,(l-1)*40+30,(h-1)*40+10);
line((l-1)*40+20,(h-1)*40+30,(l-1)*40+20,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+30,(h-1)*40+40);
line((l-1)*40+1,(h-1)*40+15,(l-1)*40+1,(h-1)*40+25);
line((l-1)*40+1,(h-1)*40+15,(l-1)*40+15,(h-1)*40+15);
line((l-1)*40+1,(h-1)*40+25,(l-1)*40+15,(h-1)*40+25);
circle((l-1)*40+25,(h-1)*40+20,5);
end;
3:begin
setcolor(green);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+40,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+30,(h-1)*40+30);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+10,(h-1)*40+1);
line((l-1)*40+1,(h-1)*40+30,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+5,(l-1)*40+10,(h-1)*40+5);
line((l-1)*40+40,(h-1)*40+20,(l-1)*40+30,(h-1)*40+20);
line((l-1)*40+40,(h-1)*40+10,(l-1)*40+30,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+20,(l-1)*40+1,(h-1)*40+20);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+1,(h-1)*40+10);
line((l-1)*40+25,(h-1)*40+40,(l-1)*40+15,(h-1)*40+40);
line((l-1)*40+25,(h-1)*40+40,(l-1)*40+25,(h-1)*40+25);
line((l-1)*40+15,(h-1)*40+40,(l-1)*40+15,(h-1)*40+25);
circle((l-1)*40+20,(h-1)*40+15,5);
end;
4:begin
setcolor(green);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+1,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+30,(h-1)*40+30);
line((l-1)*40+1,(h-1)*40+40,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+1,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+1,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+25,(h-1)*40+30,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+5,(h-1)*40+30,(l-1)*40+5,(h-1)*40+10);
line((l-1)*40+20,(h-1)*40+40,(l-1)*40+20,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+40,(l-1)*40+10,(h-1)*40+30);
line((l-1)*40+20,(h-1)*40+10,(l-1)*40+20,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+10,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+25,(l-1)*40+40,(h-1)*40+15);
line((l-1)*40+40,(h-1)*40+25,(l-1)*40+25,(h-1)*40+25);
line((l-1)*40+40,(h-1)*40+15,(l-1)*40+25,(h-1)*40+15);
circle((l-1)*40+15,(h-1)*40+20,5);
end;
end;{case}
end;{with}
end;
procedure runtank(ch:char);
begin
case ch of
'i':if tank.h>1 then dec(tank.h);
'k':if tank.h<10 then inc(tank.h);
'j':if tank.l>1 then dec(tank.l);
'l':if tank.l<15 then inc(tank.l);
'8':tank.f:=1;
'4':tank.f:=2;
'5':tank.f:=3;
'6':tank.f:=4;
'0':pushtype1(tank.l,tank.h,tank.f,bomb);
'q':halt;
end;
end;
function win:boolean;
var i:integer;
begin
for i:=1 to high(diren) do
if diren[i].f>0 then begin win:=false;exit;end;
win:=true;
end;
function lost:boolean;
var i:integer;
begin
for i:=1 to high(diren) do
if (diren[i].h=tank.h) and (diren[i].l=tank.l) and (diren[i].f>0) then
begin lost:=true;exit;end;
lost:=false;
end;
procedure runbomb;
var i,hh,hl:integer;
begin
for i:=1 to high(bomb) do
with bomb[i] do
if f>0 then
begin
hh:=hh+fx[f,1];
hl:=l+fx[f,2];
if(hl in [1..15])and
(hh in [1..10]) then
begin
h:=hh;
l:=hl;
end
else begin f:=0;pushtype1(l,h,5,fire);end;
end;
end;
procedure runfire;
var i:integer;
begin
for i:=1 to high(fire) do
begin
if fire[i].f>0 then dec(fire[i].f);
end;
end;
procedure rundiren;
var s:set of 1..4;
i,j,k,hh1,hh2,hl1,hl2:integer;
begin
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
if h>tank.h then dec(h)
else if h<tank.h then inc(h);
if l<tank.l then inc(l)
else if l>tank.l then dec(l);
end;
end;
procedure check;
var i,j:integer;
begin
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
for j:=1 to high(bomb) do
if (bomb[j].h=h) and (bomb[j].l=l) and (bomb[j].f>0)
and ((bomb[j].h<>tank.h) or (bomb[j].l<>tank.l)) then
begin
bomb[j].f:=0;f:=0;break;
end;
end;
end;
procedure inittank;
var y:integer;
ch:char;
begin
settextstyle(7,horizdir,6);
setcolor(white);
outtextxy(10,10,'Tank2:Crazy tank');
settextstyle(1,horizdir,1);
y:=100;
outtextxy(50,y,'Mase by WangYu');
inc(y,textheight('H')+1);
outtextxy(50,y,'Ctrl key:');
inc(y,textheight('H')+1);
outtextxy(50,y,'Up:i Left:j Right:l Down:k Exit:q');
inc(y,textheight('H')+1);
outtextxy(50,y,'GunUp:8 GunLeft:4 GunRight:6 Fire:0');
inc(y,textheight('H')+100);
outtextxy(50,y,'Pressed Enter to continue');
repeat ch:=readkey;until ch=#13;
end;
procedure init(ds:integer);
var i:integer;
st:string;
begin
fillchar(t,sizeof(t),0);
fillchar(diren,sizeof(diren),0);
fillchar(fire,sizeof(fire),0);
fillchar(bomb,sizeof(bomb),0);
tank.h:=5;tank.l:=8;tank.f:=1;
with diren[1] do begin h:=1;l:=7;f:=0;end;
with diren[2] do begin h:=10;l:=7;f:=0;end;
with diren[3] do begin h:=1;l:=1;f:=0;end;
with diren[4] do begin h:=10;l:=15;f:=0;end;
with diren[5] do begin h:=1;l:=15;f:=0;end;
with diren[6] do begin h:=10;l:=1;f:=0;end;
with diren[7] do begin h:=6;l:=1;f:=0;end;
with diren[8] do begin h:=6;l:=15;f:=0;end;
for i:=1 to ds do diren[i].f:=1;
str(ds,st);
print;
setcolor(black);
outtextxy(200,200,'Level'+st);
readkey;
end;
procedure main;
var ch:char;
begin
while not lost and not win do
begin
delay(50);
with t do
begin
inc(ms,50);
if ms>=1000 then
begin
ms:=0;
inc(s);
if s>=60 then
s:=0;
inc(m);
end;
end;
if keypressed then
begin
ch:=readkey;
runtank(ch);
end;
if t.ms mod 200=0 then rundiren;
if t.ms mod 100=0 then check;
if t.ms mod 100=0 then begin runbomb;lf:=true;end;
if t.ms mod 100=0 then runfire;
print;
end;
setcolor(black);
if win then outtextxy(200,200,'You win!!!')
else outtextxy(200,200,'You lost!!!');
repeat
ch:=readkey;
until ch=#13;
end;
var level:integer;
begin
initg;
inittank;
for level:=1 to 8 do
begin
init(level);
main;
if lost then dec(level);
end;
end.
program c_k;
var a,b,c:integer;
begin
randomize;
a:=random(100);
c:=0;
repeat
c:=c+1;
write('please input b:');
readln(b);
if b>a then writeln('Too big')
else if b<a then writeln('Too small')
else if b=a tehn writeln('you are right');
until (c=10) or (a=b);
if c=10 then writeln('you false,the number is:',a);
readln;readln;
end.
再送你一个坦克大战程序:
program tanke;
uses crt,graph;
type
type1=record
h,l,f:integer;
end;
time=record
ms,s,m:integer;
end;
const fx:array[1..4,1..2] of -1..1=((-1,0),(0,-1),(1,0),(0,1));
var t:time;
tank:type1;
bomb:array[1..20]of type1;
diren:array[1..8]of type1;
fire:array[1..20]of type1;
u,d,l,r,gu,gd,gl,gr:char;
lf:boolean;
procedure initg;
var gd,gm:integer;
begin
gd:=detect;
initgraph(gd,gm,'');
end;
procedure pushtype1(l,h,f:integer;var a:array of type1);
var i:integer;
begin
for i:=1 to high(a) do
if a[i].f<=0 then
begin
a[i].h:=h;a[i].l:=l;a[i].f:=f;
exit;
end;
end;
procedure print;
var i,j:integer;
begin
setfillstyle(white,1);
bar(0,0,600,400);
for i:=1 to high(fire) do
with fire[i] do
if f>0 then
begin
setcolor(red);
line(l*40-20,h*40-20,l*40-1,h*40-1);
line(l*40-20,h*40-20,l*40-1,h*40-10);
line(l*40-20,h*40-20,l*40-1,h*40-20);
line(l*40-20,h*40-20,l*40-1,h*40-30);
line(l*40-20,h*40-20,l*40-1,h*40-40);
line(l*40-20,h*40-20,l*40-40,h*40-1);
line(l*40-20,h*40-20,l*40-40,h*40-10);
line(l*40-20,h*40-20,l*40-40,h*40-20);
line(l*40-20,h*40-20,l*40-40,h*40-30);
line(l*40-20,h*40-20,l*40-40,h*40-40);
line(l*40-20,h*40-20,l*40-20,h*40-1);
line(l*40-20,h*40-20,l*40-30,h*40-1);
line(l*40-20,h*40-20,l*40-10,h*40-40);
line(l*40-20,h*40-20,l*40-10,h*40-1);
line(l*40-20,h*40-20,l*40-20,h*40-40);
line(l*40-20,h*40-20,l*40-30,h*40-40);
end;
for i:=1 to high(bomb) do
with bomb[i] do
if f>0 then
begin
setcolor(blue);
circle((l-1)*40+20,(h-1)*40+20,5);
end;
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
setcolor(11);
line((l-1)*40+5,(h-1)*40+1,(l-1)*40+15,(h-1)*40+10);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+10,(h-1)*40+15);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+1,(h-1)*40+5);
line((l-1)*40+1,(h-1)*40+5,(l-1)*40+5,(h-1)*40+1);
line((l-1)*40+35,(h-1)*40+1,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+25,(h-1)*40+10,(l-1)*40+30,(h-1)*40+15);
line((l-1)*40+30,(h-1)*40+15,(l-1)*40+40,(h-1)*40+5);
line((l-1)*40+40,(h-1)*40+5,(l-1)*40+35,(h-1)*40+1);
line((l-1)*40+5,(h-1)*40+40,(l-1)*40+15,(h-1)*40+30);
line((l-1)*40+15,(h-1)*40+30,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+10,(h-1)*40+25,(l-1)*40+1,(h-1)*40+35);
line((l-1)*40+1,(h-1)*40+35,(l-1)*40+5,(h-1)*40+40);
line((l-1)*40+35,(h-1)*40+40,(l-1)*40+25,(h-1)*40+30);
line((l-1)*40+25,(h-1)*40+30,(l-1)*40+30,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+40,(h-1)*40+35);
line((l-1)*40+40,(h-1)*40+35,(l-1)*40+35,(h-1)*40+40);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+15,(l-1)*40+30,(h-1)*40+25);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+15,(h-1)*40+25);
line((l-1)*40+15,(h-1)*40+30,(l-1)*40+25,(h-1)*40+30);
setcolor(red);
circle((l-1)*40+20,(h-1)*40+20,6);
end;
with tank do
begin
if f>0 then setcolor(green)
else setcolor(red);
case f of
0,1:begin
setcolor(green);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+1,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+10,(h-1)*40+10);
line((l-1)*40+1,(h-1)*40+40,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+30,(h-1)*40+40);
line((l-1)*40+40,(h-1)*40+10,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+15,(l-1)*40+30,(h-1)*40+15);
line((l-1)*40+10,(h-1)*40+35,(l-1)*40+30,(h-1)*40+35);
line((l-1)*40+1,(h-1)*40+20,(l-1)*40+10,(h-1)*40+20);
line((l-1)*40+1,(h-1)*40+30,(l-1)*40+10,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+20,(l-1)*40+40,(h-1)*40+20);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+40,(h-1)*40+30);
line((l-1)*40+15,(h-1)*40+1,(l-1)*40+25,(h-1)*40+1);
line((l-1)*40+15,(h-1)*40+1,(l-1)*40+15,(h-1)*40+15);
line((l-1)*40+25,(h-1)*40+1,(l-1)*40+25,(h-1)*40+15);
circle((l-1)*40+20,(h-1)*40+25,5);
end;
2:begin
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+40,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+10,(h-1)*40+10);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+40,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+40,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+40,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+10,(h-1)*40+40);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+40,(h-1)*40+40);
line((l-1)*40+15,(h-1)*40+10,(l-1)*40+15,(h-1)*40+30);
line((l-1)*40+35,(h-1)*40+10,(l-1)*40+35,(h-1)*40+30);
line((l-1)*40+20,(h-1)*40+1,(l-1)*40+20,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+1,(l-1)*40+30,(h-1)*40+10);
line((l-1)*40+20,(h-1)*40+30,(l-1)*40+20,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+30,(h-1)*40+40);
line((l-1)*40+1,(h-1)*40+15,(l-1)*40+1,(h-1)*40+25);
line((l-1)*40+1,(h-1)*40+15,(l-1)*40+15,(h-1)*40+15);
line((l-1)*40+1,(h-1)*40+25,(l-1)*40+15,(h-1)*40+25);
circle((l-1)*40+25,(h-1)*40+20,5);
end;
3:begin
setcolor(green);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+40,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+30,(l-1)*40+30,(h-1)*40+30);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+1,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+10,(h-1)*40+1);
line((l-1)*40+1,(h-1)*40+30,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+30,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+1,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+25,(l-1)*40+10,(h-1)*40+25);
line((l-1)*40+30,(h-1)*40+5,(l-1)*40+10,(h-1)*40+5);
line((l-1)*40+40,(h-1)*40+20,(l-1)*40+30,(h-1)*40+20);
line((l-1)*40+40,(h-1)*40+10,(l-1)*40+30,(h-1)*40+10);
line((l-1)*40+10,(h-1)*40+20,(l-1)*40+1,(h-1)*40+20);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+1,(h-1)*40+10);
line((l-1)*40+25,(h-1)*40+40,(l-1)*40+15,(h-1)*40+40);
line((l-1)*40+25,(h-1)*40+40,(l-1)*40+25,(h-1)*40+25);
line((l-1)*40+15,(h-1)*40+40,(l-1)*40+15,(h-1)*40+25);
circle((l-1)*40+20,(h-1)*40+15,5);
end;
4:begin
setcolor(green);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+1,(h-1)*40+40);
line((l-1)*40+30,(h-1)*40+30,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+40,(l-1)*40+30,(h-1)*40+30);
line((l-1)*40+1,(h-1)*40+40,(l-1)*40+1,(h-1)*40+30);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+1,(h-1)*40+10);
line((l-1)*40+30,(h-1)*40+1,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+30,(h-1)*40+10,(l-1)*40+30,(h-1)*40+1);
line((l-1)*40+1,(h-1)*40+10,(l-1)*40+1,(h-1)*40+1);
line((l-1)*40+25,(h-1)*40+30,(l-1)*40+25,(h-1)*40+10);
line((l-1)*40+5,(h-1)*40+30,(l-1)*40+5,(h-1)*40+10);
line((l-1)*40+20,(h-1)*40+40,(l-1)*40+20,(h-1)*40+30);
line((l-1)*40+10,(h-1)*40+40,(l-1)*40+10,(h-1)*40+30);
line((l-1)*40+20,(h-1)*40+10,(l-1)*40+20,(h-1)*40+1);
line((l-1)*40+10,(h-1)*40+10,(l-1)*40+10,(h-1)*40+1);
line((l-1)*40+40,(h-1)*40+25,(l-1)*40+40,(h-1)*40+15);
line((l-1)*40+40,(h-1)*40+25,(l-1)*40+25,(h-1)*40+25);
line((l-1)*40+40,(h-1)*40+15,(l-1)*40+25,(h-1)*40+15);
circle((l-1)*40+15,(h-1)*40+20,5);
end;
end;{case}
end;{with}
end;
procedure runtank(ch:char);
begin
case ch of
'i':if tank.h>1 then dec(tank.h);
'k':if tank.h<10 then inc(tank.h);
'j':if tank.l>1 then dec(tank.l);
'l':if tank.l<15 then inc(tank.l);
'8':tank.f:=1;
'4':tank.f:=2;
'5':tank.f:=3;
'6':tank.f:=4;
'0':pushtype1(tank.l,tank.h,tank.f,bomb);
'q':halt;
end;
end;
function win:boolean;
var i:integer;
begin
for i:=1 to high(diren) do
if diren[i].f>0 then begin win:=false;exit;end;
win:=true;
end;
function lost:boolean;
var i:integer;
begin
for i:=1 to high(diren) do
if (diren[i].h=tank.h) and (diren[i].l=tank.l) and (diren[i].f>0) then
begin lost:=true;exit;end;
lost:=false;
end;
procedure runbomb;
var i,hh,hl:integer;
begin
for i:=1 to high(bomb) do
with bomb[i] do
if f>0 then
begin
hh:=hh+fx[f,1];
hl:=l+fx[f,2];
if(hl in [1..15])and
(hh in [1..10]) then
begin
h:=hh;
l:=hl;
end
else begin f:=0;pushtype1(l,h,5,fire);end;
end;
end;
procedure runfire;
var i:integer;
begin
for i:=1 to high(fire) do
begin
if fire[i].f>0 then dec(fire[i].f);
end;
end;
procedure rundiren;
var s:set of 1..4;
i,j,k,hh1,hh2,hl1,hl2:integer;
begin
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
if h>tank.h then dec(h)
else if h<tank.h then inc(h);
if l<tank.l then inc(l)
else if l>tank.l then dec(l);
end;
end;
procedure check;
var i,j:integer;
begin
for i:=1 to high(diren) do
with diren[i] do
if f>0 then
begin
for j:=1 to high(bomb) do
if (bomb[j].h=h) and (bomb[j].l=l) and (bomb[j].f>0)
and ((bomb[j].h<>tank.h) or (bomb[j].l<>tank.l)) then
begin
bomb[j].f:=0;f:=0;break;
end;
end;
end;
procedure inittank;
var y:integer;
ch:char;
begin
settextstyle(7,horizdir,6);
setcolor(white);
outtextxy(10,10,'Tank2:Crazy tank');
settextstyle(1,horizdir,1);
y:=100;
outtextxy(50,y,'Mase by WangYu');
inc(y,textheight('H')+1);
outtextxy(50,y,'Ctrl key:');
inc(y,textheight('H')+1);
outtextxy(50,y,'Up:i Left:j Right:l Down:k Exit:q');
inc(y,textheight('H')+1);
outtextxy(50,y,'GunUp:8 GunLeft:4 GunRight:6 Fire:0');
inc(y,textheight('H')+100);
outtextxy(50,y,'Pressed Enter to continue');
repeat ch:=readkey;until ch=#13;
end;
procedure init(ds:integer);
var i:integer;
st:string;
begin
fillchar(t,sizeof(t),0);
fillchar(diren,sizeof(diren),0);
fillchar(fire,sizeof(fire),0);
fillchar(bomb,sizeof(bomb),0);
tank.h:=5;tank.l:=8;tank.f:=1;
with diren[1] do begin h:=1;l:=7;f:=0;end;
with diren[2] do begin h:=10;l:=7;f:=0;end;
with diren[3] do begin h:=1;l:=1;f:=0;end;
with diren[4] do begin h:=10;l:=15;f:=0;end;
with diren[5] do begin h:=1;l:=15;f:=0;end;
with diren[6] do begin h:=10;l:=1;f:=0;end;
with diren[7] do begin h:=6;l:=1;f:=0;end;
with diren[8] do begin h:=6;l:=15;f:=0;end;
for i:=1 to ds do diren[i].f:=1;
str(ds,st);
print;
setcolor(black);
outtextxy(200,200,'Level'+st);
readkey;
end;
procedure main;
var ch:char;
begin
while not lost and not win do
begin
delay(50);
with t do
begin
inc(ms,50);
if ms>=1000 then
begin
ms:=0;
inc(s);
if s>=60 then
s:=0;
inc(m);
end;
end;
if keypressed then
begin
ch:=readkey;
runtank(ch);
end;
if t.ms mod 200=0 then rundiren;
if t.ms mod 100=0 then check;
if t.ms mod 100=0 then begin runbomb;lf:=true;end;
if t.ms mod 100=0 then runfire;
print;
end;
setcolor(black);
if win then outtextxy(200,200,'You win!!!')
else outtextxy(200,200,'You lost!!!');
repeat
ch:=readkey;
until ch=#13;
end;
var level:integer;
begin
initg;
inittank;
for level:=1 to 8 do
begin
init(level);
main;
if lost then dec(level);
end;
end.
参考资料: hi.baidu.com/wywy
展开全部
楼上的,一个字:猛!!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
一堆一堆的程序,再由几个主程序把这些一堆一堆的程序调用,这些程序又将分支程序调用。。。
于是。。。游戏就这么出来了。。。
程序中用了图形单元等各类单元使游戏更生动形象等等。。。
如果你要用Pascal做一个游戏,你得打上上百个程序才能成为一个游戏。
当然,也有小的游戏,你可以打上上千行的代码,这样就有一个小游戏了~
于是。。。游戏就这么出来了。。。
程序中用了图形单元等各类单元使游戏更生动形象等等。。。
如果你要用Pascal做一个游戏,你得打上上百个程序才能成为一个游戏。
当然,也有小的游戏,你可以打上上千行的代码,这样就有一个小游戏了~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询