一个双人的游戏 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.
 
 

Pascal小游戏 双人射击的更多相关文章

  1. Pascal小游戏 不要消灭星星

    不要消灭星星 Pascal小游戏 Chaobs改编自pascal吧 控制台小游戏嘛,就当是练习一下结构化的写法. program wxtw; uses crt; type      zbdy=reco ...

  2. Pascal小游戏 文件的产生

    一个整人的Pascal小程序 运行之后硬盘里面会有一大堆垃圾,当然更好的方法当然不是这样做! var a,b,c,d:char;beginfor a:='0' to '9' dofor b:='0' ...

  3. Pascal小游戏之奇葩的RPG

    Pascal吧友作品 一个小RPG Chaobs转载 varplife,plifemax,patt,pre:integer;gr,ex,exmax:integer;alife,alife1,aatt, ...

  4. Pascal小游戏 俄罗斯方块怀旧版

    俄罗斯方块怀旧版(注释版) {$APPTYPE GUI}{$MODE DELPHI}program WinPiece; usesWindows; constAppName = 'WinPiece';p ...

  5. Pascal小游戏 随机函数

    一个被人写滥了的小程序,新手学习,Pascal By Chaobs 初学者可以用它来学习随机函数的运用,当然你完全可以自己写一个随机函数. var   player1,player2:longint; ...

  6. Pascal小游戏 打飞机

    一个经典的打飞机游戏(1)Pascal代码 十分经典,有一种街机的感觉 奇葩青年的又一控制台神作. uses crt; type list=record         ty,ax:integer;  ...

  7. Pascal小游戏 井字棋

    一个很经典的井字棋游戏 Pascal源码Chaobs奉上 注意:1.有的FP版本不支持汉语,将会出现乱码.2.别想赢电脑了,平手不错了. 井字过三关: program TicTacToe; uses ...

  8. Pascal小游戏 贪吃蛇

    一段未完成的Pascal贪吃蛇 说这段代码未完成其实是没有源代码格式化,FP中一行最多只有255字符宽. uses crt; const screenwidth=50; screenheight=24 ...

  9. Pascal小游戏 俄罗斯方块

    俄罗斯方块已经成为了和“Hello World”一样的程序了吧? 不要直接复制,可能需要事先 Format. program cube;uses crt,graph,dos;var gd,gm:sma ...

随机推荐

  1. S7-1500 读取V90/S120/S210/G120的常用驱动参数

    S7-1500 读取V90/S120的常用驱动参数 此程序已更新,可以下载例子程序 https://files.cnblogs.com/files/lion-zheng/PLC_async_drive ...

  2. WSL的unable to resolve host问题

    运行apt-get的时候提示 sudo: unable to resolve host DESKTOP-PS8VD9E 在 /etc/hosts文件中 127.0.0.1 对应主机名字给加一行就好了

  3. robotframework实战二---Jenkins连用

    1.下载插件robot Jenkins环境搭建就不用说了,网上有很多帖子,你在使用时,你需要做以下几步 因为目前我已经安装了 2.新建项目 因为有重名的项目,所以会提示以下内容 你需要配置的内容就两处 ...

  4. SVN知识集合

    1. 如果某个项目之前保存了A仓库的信息,无法切换到B仓库(通过AnkhSVN或者VisualSVN),可以先在本地去除版本控制(用TortoiseSVN),然后导出B仓库信息(用TortoiseSV ...

  5. Windows 7下的ARP

    关于Windows 7和Windows XP下的ARP绑定的不同之处网络上已经很多,没空就不多说,注意用这样的方式绑定的arp项是动态的,动态的意思就是这个项不受任何保护,Windows想什么时候更改 ...

  6. 尝试将 SCRIPT ompbox\private\ompmex 作为函数执行

    1.安装VS2010 2.配置ombox 在ombox路径下 mex -setup C++ 然后 make

  7. mapping4java源码下载(alibab的开源项目)

    项目中需要频繁实现json-->pojo,Bean-->Bean的转换,使用了mapping4java这个开源的框架: 网上查资料,该框架是愤怒的苹果提供的,附上原文地址 我也造了个轮子: ...

  8. 通过ip地址访问同一局域网下已经启动的angular项目

    通常tomcat启动的项目同一局域网下我们都可以访问.angular启动的前台项目别人怎么访问,一直不懂,后来知道启动命令加个参数就行了 首先查看本机ip 第二步,启动命令里加上--host 本机ip ...

  9. C#基础-面向对象-封装

    封装 命名空间 using System; using System.Collections.Generic; using System.Text; namespace ConsoleApp6 { c ...

  10. linux环境下安装 openOffice 并启动服务

    一.背景故事 这两天遇到一个大坑,客户要做office 文档在线预览功能,于是乎就要把office文档转换成pdf交给前端显示.      在某度找了一圈都说openOffice+jodconvert ...