• Pascal小游戏 双人射击


    一个双人的游戏 Pascal源码附上

    只要俩人不脑残,一下午玩不完。。。
    又是控制台游戏中的一朵奇葩。
    Free Pascal 射击游戏
    Program shooting_game;
    uses crt;
    const cz:array[1..4,1..2] of -1..1=((0,1),(1,0),(0,-1),(-1,0));
    var i,j,xz1,yz1,y1,xz2,yz2,y2,t1,t2,t3,k,v1,v2:integer;
        ch:char;
        a:array[1..20] of integer;
    
    
    procedure priter;
    begin
         gotoxy(1,1);
         textbackground(green);
         for i:=1 to 20 do
         begin
              for j:=1 to 40 do
                  write(' ');
              writeln;
         end;
    end;
    procedure priv;
    begin
         gotoxy(1,1);
         write('v1:',v1:3,'               v2:',v2:2);
    end;
    procedure start;
    begin
         priter;
         textcolor(black);
         textbackground(green);
         gotoxy(1,1);
         write('Really?  ');
         ch:=readkey;
         for i:=3 downto 1 do
         begin
              write(i);
              sound(1871);
              delay(500);
              nosound;
              delay(500);
              write(#8);
         end;
         write('Go!!!');
         sound(2500);
         delay(500);
         nosound;
    end;
    procedure GameOver(p:integer);
    begin
         if p=1 then begin gotoxy(1,y1);write(']*');end;
         if p=2 then begin gotoxy(39,y2);write('*[');end;
         textcolor(green);
         textbackground(black);
         gotoxy(10,10);
         p:=3-p;
         write('Player  ',p:1,'  is Win!!!');
         repeat ch:=readkey;until ord(ch)=13;
         textbackground(black);
         ClrScr;
         halt;
    end;
    procedure over(p:integer);
    begin
         if p=1 then begin dec(v1);gotoxy(1,y1);write(']*');end;
         if p=2 then begin dec(v2);gotoxy(39,y2);write('*[');end;
         priv;
         if v1=0 then gameover(1);
         if v2=0 then gameover(2);
    end;
    procedure go;
    begin
         textbackground(black);
         ClrScr;
         for i:=1 to 20 do a[i]:=38;
         textbackground(green);
         textcolor(black);
         priter;
         gotoxy(1,2);
         y1:=1;
         write(']>');
         gotoxy(39,2);
         write('<[');
         gotoxy(1,1);
         y1:=2;t1:=0;t2:=0;t3:=0;y2:=2;v1:=10;v2:=10;
         priv;
         while true do
         begin
              delay(1);
              inc(t1,1);
              if t1=1000 then
              begin
                   inc(t2);
                   if t2=60 then begin t2:=0;inc(t3);end;
              end;
              if keypressed then
              begin
                   ch:=readkey;
                   if (ch='i') and (y1>2) then
                   begin
                        gotoxy(1,y1);
                        write('  ');
                        dec(y1);
                        gotoxy(1,y1);
                        write(']>');
                   end;
                   if (ch='k') and (y1<20) then
                   begin
                        gotoxy(1,y1);
                        write('  ');
                        inc(y1);
                        gotoxy(1,y1);
                        write(']>');
                   end;
                   if (ch='q') then break;
                   if (ch='f')and(xz1=0) then
                   begin
                        xz1:=3;
                        yz1:=y1;
                   end;
                   {play2}
                   if (ch='8') and (y2>2) then
                   begin
                        gotoxy(39,y2);
                        write('  ');
                        dec(y2);
                        gotoxy(39,y2);
                        write('<[');
                   end;
                   if (ch='5') and (y2<20) then
                   begin
                        gotoxy(39,y2);
                        write('  ');
                        inc(y2);
                        gotoxy(39,y2);
                        write('<[');
                   end;
                   if (ch='0')and(xz2=0) then
                   begin
                        xz2:=37;
                        yz2:=y2;
                   end;
              end;{end of keyprssed}
              if (t1 mod 5=0)and(xz1<>0) then
              begin
                   if xz1>38 then
                   begin
                        gotoxy(xz1,yz1);
                        write('  ');
                        if yz1=y2 then Over(2);
                        xz1:=0;
                        yz1:=0;
                   end
                   else
                   begin
                        gotoxy(xz1,yz1);
                        write(' .');
                        inc(xz1);
                   end;
              end;
              {play2}
              if (t1 mod 5=0)and(xz2<>0) then
              begin
                   if xz2<2 then
                   begin
                        gotoxy(xz2,yz2);
                        write(' ');
                        if yz2=y1 then Over(1);
                        xz2:=0;
                        yz2:=0;
                   end
                   else
                   begin
                        gotoxy(xz2-1,yz2);
                        write('. ');
                        dec(xz2);
                   end;
              end;
         end;{end of while}
    end; {end of go}
    begin
         start;
         go;
    end.
     
    不要想你能为世界做什么,想想你该为世界做什么!
  • 相关阅读:
    android studio常用快捷键
    html5开发之viewport使用
    Android之 -WebView实现离线缓存阅读
    Android总结篇系列:Activity生命周期
    设计模式系列(0)
    通过Jni实现AES的CBC模式加密解密
    Android Studio通过JNI调用NDK程序
    Android Studio] Gradle项目中添加JNI生成文件(.so文件)
    Android Studio开发JNI工程
    Java中RSA非对称密钥加解密使用示例
  • 原文地址:https://www.cnblogs.com/Chaobs/p/3837478.html
Copyright © 2020-2023  润新知