回 帖 发 新 帖 刷新版面

主题:[原创]贪食蛇+扫雷 2 in 1 游戏,中文界面!!

这是lzl1403使用Turbo Pascal 7.0编的,我只不过是帮他贴上来的。

编译此程序必需的文件:
GRAPH.TPU    TP7自带
EGAVGA.BGI   TP7自带
GOTH.CHR     TP7自带
TSCR.CHR     TP7自带
HZK16       UCDOS 的16*16汉字点阵。具体请参阅[url]http://www.programfan.com/club/showbbs.asp?id=14025[/url]
另外,没有Crt补丁的请在此下载:
[url]http://www.mydrs.org/program/list.asp?id=136[/url]

首先运行这个安装来安装:
prooram setup;
begin
  assign(output,'hero.dat');
  rewrite(output);
  writeln(0);
  close(output);
end.

运行了安装程序并齐备必需文件后就可以玩游戏了:
PROGRAM biogame;
uses Graph,Crt,Dos;
label 99;
var
grDriver: Integer;
grMode: Integer;
ErrCode: Integer;
game:integer;
ch:char;
{==========OutChinese==============}
procedure putone(x,y:integer;s:string;color:integer);
type
    chinesep=array[1..32] of byte;
var
    a:chinesep;
    f:file of chinesep;
    i,j,x0,y0:integer;
    k:byte;
    q,w:longint;

begin
    q:=ord(s[1])-160;
    w:=ord(s[2])-160;
    q:=(q-1)*94+(w-1);
    assign(f,'HZK16') ;
    reset(f);
    if (q<0) or (q>=filesize(f)) then
      begin
         close(f);
         exit;
      end;
    seek(f,q);
    read(f,a);
    close(f);
    y0:=y;
    for i:=1 to 32 do
     begin
       k:=a[i];
       if i mod 2=1 then
         begin
           x0:=7+x;
           y0:=y0+1;
         end
        else
              x0:=15+x;
       for j:=1 to 8 do
        begin
           if k and 1 =1 then putpixel(x0,y0,color);
            x0:=x0-1;
            k:=k shr 1;
        end;
     end;
end;

procedure outchinese(x,y:integer;s:string;blank:integer; color:integer);
var
   temps:string;
   k:integer;
begin
   k:=1;
   while k<length(s) do
    begin
       temps:=s[k]; k:=k+1;
       temps:=temps+s[k]; k:=k+1;
       putone(x+(k div 2-1)*(16+blank),y,temps,color);
    end;
end;

PROCEDURE MineSweeper;
CONST
  maxsize=15;
  rnd:array[1..8,1..2]of shortint=((0,1),(1,0),(0,-1),(-1,0),(1,1),(-1,-1),(1,-1),(-1,1));
  bug='I will die!';

VAR
  grDriver: Integer;
  grMode: Integer;
  ErrCode: Integer;
  sign:array[0..maxsize,0..maxsize]of 1..3;{1:No put 2:Put 3:Sign}
  mine:array[0..maxsize,0..maxsize]of shortint;{-1:Mine 0:Safety 1..8:Danger}
  safe,sweep:array[0..maxsize,0..maxsize]of boolean;
  man:record
        x,y:word;
      end;
  size,hard,total:integer;
  ff,fk:boolean;
  hh,mm,ss,ms:integer;
  hh1,mm1,ss1,ms1,hh2,mm2,ss2,ms2:word;
  s:string;

回复列表 (共40个回复)

11 楼

继续继续!太高兴了!

12 楼

哇!10分钟内发了10个帖,系统会怀疑有灌水行为的喔!

13 楼

期待明天继续!再顶一下!

14 楼

咦,程序怎么好像乱了,楼主检查一下有没有哪一部分漏了。

15 楼

太长了

16 楼

begin
grDriver := Detect;
InitGraph(grDriver, grMode,' ');
ErrCode := GraphResult;
if ErrCode = grOk then
begin  { Do graphics }
   f1:=true;
   while f1 do
   begin
    cleardevice;
    outchinese(50,100,'方向键  控制方向',0,11);
    outchinese(50,150,'空格键  暂停游戏',0,11);
    setcolor(11);
    settextstyle(0,0,1);
    outtextxy(50,205,'Esc');
    outchinese(50,200,'    键  退出游戏',0,11);
    outchinese(50,250,'请选择难度',0,10);
    setcolor(10);
    outtextxy(140,255,'(1--9)');
    chh:=readkey;
    hard:=ord(chh)-48;
    if (hard>=1)and(hard<=9)
    then f1:=false;
   end;
   cleardevice;
   randomize;
   long:=slong;
   x1:=long+1;
   y1:=1;
   setcolor(13);
   rectangle(step div 2-1,step div 2-1,GetMaxX-step+1,GetMaxY-step+1);
   setcolor(3);
   rectangle(x1*step-step div 2,y1*step-step div 2,x1*step+step div 2,y1*step+step div 2);
   settextstyle(0,0,2);
   outtextxy(x1*step-trunc(step/2.5),y1*step-trunc(step/2.5),head);
   for i:=1 to long do
   begin
     snake[i].y:=1;
     snake[i].x:=i;
     rectangle(snake[i].x*step-step div 2,snake[i].y*step-step div 2,snake[i].x*step+step div 2,snake[i].y*step+step div 2);
   end;
   repeat
     nutx:=random((GetMaxX div step)-1)+1;
     nuty:=random((GetMaxY div step)-1)+1;
     f1:=true;
     for i:=1 to long do
       if (snake[i].x=nutx)and(snake[i].y=nuty)
       then begin f1:=false;break;end;
     if (nutx=x1)and(nuty=y1)
     then begin f1:=false;break;end;
   until f1;
   setcolor(4);
   settextstyle(0,0,2);
   outtextxy(nutx*step-trunc(step/2.5),nuty*step-trunc(step/2.5),nut);
   rectangle(nutx*step-step div 2,nuty*step-step div 2,nutx*step+step div 2,nuty*step+step div 2);

17 楼

ch:=readkey;
   setcolor(GetBKColor);
   rectangle(step-step div 2,step-step div 2,step+step div 2,step+step div 2);
   p:=1;
   dirc:=4;
   repeat
     case ch of
       #72:if dirc<>2 then dirc:=1;
       #80:if dirc<>1 then dirc:=2;
       #75:if dirc<>4 then dirc:=3;
       #77:if dirc<>3 then dirc:=4;
       #13:repeat until keypressed;
     end;
     while not keypressed do
     begin
       snake[p].x:=x1;
       snake[p].y:=y1;
       p:=p+1;
       if p>long
       then p:=1;
       setcolor(GetBKColor);
       rectangle(x1*step-step div 2,y1*step-step div 2,x1*step+step div 2,y1*step+step div 2);
       settextstyle(0,0,2);
       outtextxy(x1*step-trunc(step/2.5),y1*step-trunc(step/2.5),head);
       case dirc of
         1:dec(y1);
         2:inc(y1);
         3:dec(x1);
         4:inc(x1);
       end;
       if (x1=0)or(y1=0)or(x1=GetMaxX div step)or(y1=GetMaxY div step)
       then begin lost;exit;end;
       for i:=1 to long do
         if (snake[i].x=x1)and(snake[i].y=y1)
         then begin lost;exit;end;
       if (x1=nutx)and(y1=nuty)
       then begin
              inc(long);
              snake[long].x:=x1;
              snake[long].y:=y1;
              setcolor(GetBKColor);
              settextstyle(0,0,2);

18 楼

outtextxy(nutx*step-trunc(step/2.5),nuty*step-trunc(step/2.5),nut);
              rectangle(nutx*step-step div 2,nuty*step-step div 2,nutx*step+step div 2,nuty*step+step div 2);
              repeat
                nutx:=random((GetMaxX div step)-1)+1;
                nuty:=random((GetMaxY div step)-1)+1;
                f1:=true;
                for i:=1 to long do
                  if (snake[i].x=nutx)and(snake[i].y=nuty)
                  then begin f1:=false;break;end;
                if (nutx=x1)and(nuty=y1)
                then f1:=false;
              until f1;
              setcolor(4);
              settextstyle(0,0,2);
              outtextxy(nutx*step-trunc(step/2.5),nuty*step-trunc(step/2.5),nut);
              rectangle(nutx*step-step div 2,nuty*step-step div 2,nutx*step+step div 2,nuty*step+step div 2);
            end;
       setcolor(GetBKColor);
       rectangle(snake[p].x*step-step div 2,snake[p].y*step-step div 2,snake[p].x*step+step div 2,snake[p].y*step+step div 2);
       setcolor(3);
       rectangle(x1*step-step div 2,y1*step-step div 2,x1*step+step div 2,y1*step+step div 2);
       settextstyle(0,0,2);
       outtextxy(x1*step-trunc(step/2.5),y1*step-trunc(step/2.5),head);
       for i:=1 to long do
       if i<>p
       then rectangle(snake[i].x*step-step div 2,snake[i].y*step-step div 2,
              snake[i].x*step+step div 2,snake[i].y*step+step div 2);
       setcolor(4);
       settextstyle(0,0,2);
       outtextxy(nutx*step-trunc(step/2.5),nuty*step-trunc(step/2.5),nut);
       rectangle(nutx*step-step div 2,nuty*step-step div 2,nutx*step+step div 2,nuty*step+step div 2);
       delay(550-hard*50);
     end;
     ch:=readkey;
   until ch=#27;
   CloseGraph;
end
else
   Writeln('Graphics error:', GraphErrorMsg(ErrCode));
end;

19 楼

BEGIN
99: grDriver := Detect;
InitGraph(grDriver, grMode,' ');
ErrCode := GraphResult;
if ErrCode = grOk then
begin  { Do graphics }
  cleardevice;
  OutChinese(160,150,'游戏选择',0,10);
  OutChinese(250,250,'扫雷',0,9);
  OutChinese(250,300,'贪食蛇',0,3);
  OutChinese(250,350,'退出',0,3);
  SetColor(2);
  SetTextStyle(0,0,3);
  OutTextXY(190,250,chr(26));
  game:=1;
  repeat
    ch:=readkey;
    case ch of
      #72:begin{====Up====}
            SetColor(0);
            OutTextXY(190,200+50*game,chr(26));
            game:=game-1;
            if game<1
            then game:=3;
            SetColor(2);
            OutTextXY(190,200+50*game,chr(26));
          end;
      #80:begin{===Down===}
            SetColor(0);
            OutTextXY(190,200+50*game,chr(26));
            game:=game+1;
            if game>3
            then game:=1;
            SetColor(2);
            OutTextXY(190,200+50*game,chr(26));
          end;
    end;
    OutChinese(250,250,'扫雷',0,3);
    OutChinese(250,300,'贪食蛇',0,3);
    OutChinese(250,350,'退出',0,3);
    case game of
      1:OutChinese(250,250,'扫雷',0,9);
      2:OutChinese(250,300,'贪食蛇',0,9);
      3:OutChinese(250,350,'退出',0,9);
    end;
  until ch=#13;
  cleardevice;
  case game of
    1:minesweeper;
    2:snake;
    3:halt;
  end;
  goto 99;
   CloseGraph;
end
else
   Writeln('Graphics error:', GraphErrorMsg(ErrCode));
END.

20 楼

吁~~终于贴完了!

我来回复

您尚未登录,请登录后再回复。点此登录或注册