pascal游戏吧 关注:1,980贴子:4,975

pascal游戏吧欢迎您

只看楼主收藏回复

希望大家能在此分享pascal游戏的程


1楼2006-04-22 19:15回复
    很少人会像你那样整天编游戏程序的哦!


    2楼2006-05-02 22:10
    收起回复
      你都很厉害啦!


      4楼2006-05-03 17:45
      收起回复
        • 123.253.10.*
        .


        6楼2007-10-11 18:39
        回复
          program han;//这是我没事时编的,请各位大牛多多指教!
             uses crt,dos;
             const
               stake:array[1..3]of char=('a','b','c');
             type node1=record
                    x,y:integer;
                    end;
                  node=record
                     x,y:integer;
                     nn:array[3..16]of integer;
                  end;
                tnode=array[1..10]of byte;
             var a:array['a'..'c']of node;
                 tt:array[1..10]of word;
                 guang:array[0..5]of node1;
                 now,goal:tnode;
                 n,i,step,t:integer;
                 restart,yi,bool:boolean;
             procedure built;
             var i,j,k:integer;ch:char;
             begin
               clrscr;
               write('*******/    1.重新开始   2.帮助一步   3.帮助全部 ');
               write(' 步数[     ]   目标柱[ ]     \******');
               guang[2].x:=53;guang[2].y:=1;
               guang[3].x:=67;guang[3].y:=1;
               j:=40-(n*2+2);
               textcolor(red);
               for i:=3to n+5 do
               begin
                 gotoxy(j,i);
                 write('|');
                 gotoxy(40,i);
                 write('|');
                 gotoxy(40+n*2+2,i);
                 write('|');
               end;
               for ch:='a' to 'c' do
                 with a[ch]do
                 begin
                   case ch of
                     'a':x:=j;
                     'b':x:=40;
                     'c':x:=40+n+n+2;
                     end;
                   y:=i;
                   gotoxy(x,y+3);
                   write(upcase(ch));
                 end;
               j:=j-n-3;
               gotoxy(j,i+1);
               write('/');
               for k:=1to 3*n*2+9 do
                 write('~');
               write('\');
          


          IP属地:上海7楼2010-01-03 17:09
          回复
                 gotoxy(j,i+2);
                 for k:=1to 3*n*2+11 do
                   write('~');
                 guang[1].x:=1;
                 guang[1].y:=i+4;
               end;
               procedure chushi;
               var i,j:integer;
               begin
                 clrscr;
                 textbackground(blue);
                 for i:=1to 25 do
                 begin
                   for j:=1to 2 do
                     write('                                         ');
                   writeln;
                 end;
               end;
               procedure zidong;
               var i,j,l,ll,x,lll:integer;asdf:array[1..10]of boolean;
               begin
                  randomize;l:=0;ll:=0;
                  fillchar(asdf,sizeof(asdf),false);
                  for i:=1to 3 do
                  begin
                    if i=3 then
                      l:=n-ll else begin if l>n then l:=0 else l:=random(n-l)+1;end;
                    ll:=ll+l;
                    x:=random(n)+1;
                    for j:=1to l do
                    begin
                      lll:=0;
                      while asdf[x] do
                      begin
                        if lll>10 then begin zidong;exit;end else inc(lll);
                        x:=(x mod n)+1;
                      end;
                      asdf[x]:=true;
                      now[x]:=i;
                    end;
                  end;
                 t:=random(3)+1;
                 gotoxy(guang[3].x,guang[3].y);
                 write(upcase(chr(ord('a')+t-1)));
                 gotoxy(guang[2].x,guang[2].y);
                 write(step:4);
                 for i:=1to n do
                   goal[i]:=t;
               end;
               procedure move1(aa,b:integer);
               var i:integer;
               begin
                 with a[chr(ord('a')+b-1)] do
                 begin
                 gotoxy(x-aa,y);
                 nn[y]:=aa;
            


            IP属地:上海8楼2010-01-03 17:09
            回复
                   for i:=1 to 2*aa+1 do
                     if i=aa+1 then write(aa)else
                       write('-');
                   y:=y-1;
                   end;
                 end;
                 procedure built1;
                 var i:integer;
                 begin
                   for i:=n downto 1 do
                     move1(i,now[i]);
                 end;
                 procedure move(a1,a2:char);
                 var i,j,x1:integer;
                 begin
                   with a[a1] do
                   begin
                     inc(y);
                     x1:=nn[y];
                     gotoxy(x-nn[y],y);
                     for i:=1to 2*nn[y]+1 do
                       if i=nn[y]+1 then
                         write('|')else
                         write(' ');
                     now[nn[y]]:=ord(a2)-ord('a')+1;
                   end;
                   with a[a2] do
                   begin
                     gotoxy(x-x1,y);
                     for i:=1to 2*x1+1 do
                       if i=x1+1 then write(x1) else
                         write('-');
                     nn[y]:=x1;
                     dec(y);
                   end;
                   if a[chr(ord('a')+t-1)].nn[6]=1 then
                   begin
                     bool:=true;
                     delay(1000);
                   end;
                 end;
                 procedure head;
                 const na:array[1..7]of string=('经','典','汉','诺','塔','游','戏');
                 var i,j:integer;
                 begin
                   clrscr;
                   built;
                   zidong;
                   built1;
                   textcolor(red+blue);
                   for j:=1to 2 do
                   begin
                   gotoxy(30,6);
                   for i:=1to 7 do
                   begin
                     write(na[i],' ');
                     delay(300);
                   end;
                   textcolor(green);
                   gotoxy(1,6);clreol;
                   end;
                   gotoxy(30,6);
                   textcolor(red+green);
                   for i:=1to 7 do
                     write(na[i],' ');
                   textcolor(green);
                   gotoxy(31,18);
                   write('信 息 学 奥 赛 组');
              


              IP属地:上海9楼2010-01-03 17:09
              回复
                     delay(2000);
                     delline;
                     gotoxy(57,24);
                     write('---MADE BY ');textcolor(yellow);
                     write('BOY CLEVER');
                     gotoxy(33,20);
                     textcolor(red+blue);
                     write('按任意键继续');
                     readkey;
                   end;
                   procedure main;
                   var i,ii:integer;
                   procedure move2(k:integer;w:byte);
                   var i,j:word;
                   begin
                     if (now[k]=w)or(ii=1) then exit;
                     j:=6-now[k]-w;
                     for i:=k-1 downto 1 do
                       if ii<>1then move2(i,j)else exit;
                     if ii=1then exit;
                     if yi then
                     begin
                       dec(step);
                       delline;
                     end;
                     inc(step);
                     gotoxy(guang[2].x,guang[2].y);
                     write(step:4);
                     gotoxy(guang[1].x+4,guang[1].y);
                     insline;
                     write(step,'.',stake[now[k]],'-->',stake[w]);
                     move(stake[now[k]],stake[w]);
                     now[k]:=w;
                     if yi then
                     begin
                       ii:=1;
                       yi:=false;
                       exit;
                     end;
                   end;
                   begin
                     ii:=0;
                     for i:=n downto 1 do
                       move2(i,goal[i]);
                   end;
                   procedure zou;
                   var jieshu,uu,bu:boolean;ch1,ch2:char;
                   procedure panduan(b:integer;var aaa:char);
                   var i,jj:integer;
                   begin
                     i:=b;
                     if i=1 then
                     case aaa of
                       '1':begin restart:=true;clrscr;end;
                       '2':begin yi:=true;main;uu:=true;end;
                       '3':begin delline;dec(step);main;jieshu:=true;end;
                       else
                     begin
                     repeat
                     bu:=false;
                     while (aaa<>'a')and(aaa<>'b')and(aaa<>'c')do
                     begin
                       write('错误!请重输: ');
                       aaa:=readkey;
                       b:=3;
                     end;
                     with a[aaa]do
                       if nn[y+1]=0 then begin aaa:=readkey;
                


                IP属地:上海10楼2010-01-03 17:09
                回复
                           bu:=true;end;
                       until (not bu);
                       if b=3 then
                       begin
                         write(upcase(aaa));
                         gotoxy(guang[1].x+4,guang[1].y);
                         insline;
                         write(step,'.');if i=2then write(ch1,'-->');
                       end;
                       end;
                       end else
                       begin
                       repeat
                       jj:=0;
                       bu:=false;
                       while (aaa<>'a')and(aaa<>'b')and(aaa<>'c')do
                       begin
                         write('错误!请重输: ');
                         aaa:=readkey;
                         b:=3;
                       end;
                       with a[ch1] do
                         jj:=nn[y+1];
                       with a[aaa]do
                         if (y+1<>n+6)and (jj>nn[y+1]) then begin aaa:=readkey;
                           bu:=true;end;
                       until (not bu);
                       if b=3 then
                       begin
                         write(upcase(aaa));
                         gotoxy(guang[1].x+4,guang[1].y);
                         insline;
                         write(step,'.');if i=2then write(ch1,'-->');
                       end;
                       end;
                     end;
                     begin
                       bool:=false;uu:=false;jieshu:=false;
                       while not bool do
                       begin
                         gotoxy(guang[1].x+4,guang[1].y);
                         insline;
                         inc(step);
                         write(step,'.');
                         ch1:=readkey;
                         panduan(1,ch1);
                         if restart or jieshu then exit;
                         if not uu then
                         begin
                         write(ch1,'-->');
                         ch2:=readkey;
                         panduan(2,ch2);
                         write(ch2);
                         gotoxy(guang[2].x,guang[2].y);
                         write(step:4);
                         move(ch1,ch2);
                         end else uu:=false;
                       end;
                     end;
                     procedure time;
                     begin
                       gettime(tt[1],tt[2],tt[3],tt[4]);
                  


                  IP属地:上海11楼2010-01-03 17:09
                  回复
                         getdate(tt[5],tt[6],tt[7],tt[8]);
                       end;
                       procedure suc;
                       var x:integer;
                       begin
                         x:=0;
                         tt[9]:=tt[2];
                         tt[10]:=tt[3];
                         time;
                         if tt[2]<tt[9]then
                         begin
                           tt[2]:=tt[2]+60;
                           x:=1;
                         end;
                         tt[9]:=tt[2]-tt[9];
                         if tt[3]-x<tt[10] then
                           tt[3]:=tt[3]-x+60;
                         tt[10]:=tt[3]-tt[10];
                         clrscr;
                         gotoxy(30,6);
                         write('胜利 !');
                         gotoxy(20,10);
                         write('所用步数: ',step);
                         gotoxy(20,12);
                         write('游戏所用时间: ',tt[9],' 分 ',tt[10],' 秒.');
                       end;
                       procedure shoudong;
                       var i,j,l,x:integer;
                       begin
                           clrscr;
                           gotoxy(2,5);
                           write('手动输入圆盘:');
                           for i:=1to 3 do
                           begin
                               gotoxy(6,6+i);
                               write(chr(ord('A')+i-1),': ');
                               repeat
                               l:=ord(readkey)-ord('0');
                               until l<=n;
                               write(l,' ');
                               for j:=1to l do
                               begin
                                   repeat
                                       x:=ord(readkey)-ord('0');
                                  until x<=n;
                                  write(x,' ');
                                  now[x]:=i;
                              end;
                          end;
                          gotoxy(6,11);
                          write('目标柱是: ');
                          repeat
                              t:=ord(readkey)-ord('a')+1;
                         until (t>=1)and(t<=3);
                          write(upcase(chr(ord('a')+t-1)));
                    


                    IP属地:上海12楼2010-01-03 17:09
                    回复
                           for j:=1to n do
                              goal[j]:=t;
                         end;
                         procedure moshi;
                         var i:integer;
                         begin
                             clrscr;
                             gotoxy(32,17);
                             write('模 式 选 择: ');
                             gotoxy(36,18);
                             write('1.自动生成圆盘;');
                             gotoxy(36,19);
                             write('2.手动输入圆盘;');
                             gotoxy(32,21);
                             write('请选择:');
                             repeat
                                i:=ord(readkey)-ord('0');
                             until (i=1)or(i=2);
                             if i=1 then begin built; zidong;end else
                             begin
                             shoudong;
                             built;
                             gotoxy(guang[3].x,guang[3].y);
                           write(upcase(chr(ord('a')+t-1)));
                           gotoxy(guang[2].x,guang[2].y);
                           write(step:4);
                             end;
                         end;
                         begin
                            window(1,1,80,25);
                            chushi;
                            n:=9;
                            head;
                            clrscr;
                            guang[0].x:=32;guang[0].y:=17;
                            repeat
                            textcolor(white);
                            step:=0;restart:=false;yi:=false;
                            gotoxy(guang[0].x,guang[0].y);
                            write('请输入圆盘数: ');
                            repeat
                              n:=ord(readkey)-ord('0');
                              if (n<3)or (n>10) then write('错误!只能3到9: ');
                            until (n>=3)and(n<=10);
                            moshi;
                            built1;
                            time;
                            zou;
                            until not restart;
                            suc;
                            repeat
                              readkey;
                            until false;
                         end.
                      


                      IP属地:上海13楼2010-01-03 17:09
                      回复
                        都么什啊


                        IP属地:河北16楼2010-07-10 19:26
                        回复
                          7L写的不错嘛
                          比我写的五子棋好看多了


                          IP属地:北京17楼2011-04-18 20:38
                          收起回复