⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umine.pas

📁 DELPHI版扫雷源码
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        image1.Canvas,rect(0,16*3,16,16*4));
      gameb;
    end
    else
    begin
      lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
        image1.Canvas,rect(0,16*(15-leion[x,y]),16,16*(16-leion[x,y])));
      if leion[x,y]=0 then kong(x,y);
      if jc then gamer;
    end;
  end;
end;

procedure Tmainfrm.startarray();
var
  a,b,c,i,n:integer;
begin
  help:=10;
  shi:=0;
  js.Enabled:=false;
  lq.Enabled:=true;
  shu:=lei;
  for i:=1 to 100 do
    for n:=1 to 100 do
    begin
      leion[i,n]:=0;
      leif[i,n]:=wulei;
      leik[i,n]:=false;
      leia[i,n]:=false;
    end;
  i:=0;
  n:=xl*yl;
  randomize;
  while i<lei do
  begin
    c:=random(n);
    a:=Trunc(c/yl)+1;
    b:=c mod yl+1;
    if not leia[a,b] then
    begin
      inc(i);
      leia[a,b]:=true;
    end;
  end;
  for i:=1 to xl do
    for n:=1 to yl do
    begin
      if leia[i,n] then
      begin
        leion[i,n]:=-1;
        for a:=-1 to 1 do
          for b:=-1 to 1 do
          begin
            if (i+a>0) and (n+b>0) and (i+a<=xl) and (n+b<=yl)
            then
            begin
              if not leia[i+a,n+b] then
                inc(leion[i+a,n+b]);
            end;
          end;
      end;
    end;
end;

procedure Tmainfrm.lqrd(a, b: Integer);
var
  x,y:integer;
begin
  x:=Trunc(a/16)+1;
  y:=Trunc(b/16)+1;
  if not leik[x,y] then
  begin
    if leif[x,y]=wulei then
    begin
      leif[x,y]:=youlei;
      dec(shu);
      leishu(shu);
      lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
        image1.Canvas,rect(0,16,16,16*2));
    end
    else if leif[x,y]=youlei then
    begin
      inc(shu);
      leishu(shu);
      if n12.Checked then
      begin
        leif[x,y]:=biaoji;
        lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
          image1.Canvas,rect(0,16*2,16,16*3));
      end
      else
      begin
        leif[x,y]:=wulei;
        lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
          image1.Canvas,rect(0,0,16,16));
      end;
    end
    else
    begin
      leif[x,y]:=wulei;
      lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
        image1.Canvas,rect(0,0,16,16));
    end;
  end;
end;

procedure Tmainfrm.lqld(a, b: Integer);
var
  x,y:integer;
begin
  x:=Trunc(a/16)+1;
  y:=Trunc(b/16)+1;
  if (llei.X=llei.Y) and (llei.Y=0) then
    llei:=point(x,y);
  if (not leik[x,y])and(leif[x,y]<>youlei) then
  begin
    if leif[x,y]=biaoji then
      lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
        image1.Canvas,rect(0,16*6,16,16*7))
    else
    lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
      image1.Canvas,rect(0,16*15,16,16*16));
  end;
end;

procedure Tmainfrm.lqlm(a, b: Integer);
var
  x,y:integer;
begin
  x:=Trunc(a/16)+1;
  y:=Trunc(b/16)+1;
  if ((llei.X<>x) or (llei.Y<>y)) then
  begin
    if (not leik[llei.X,llei.Y])and(leif[x,y]<>youlei) then
      lq.Canvas.CopyRect(rect((llei.x-1)*16,(llei.y-1)*16,llei.x*16,llei.y*16),
        image1.Canvas,rect(0,0,16,16));
    llei:=point(x,y);
    if not leik[x,y] then
      lq.Canvas.CopyRect(rect((x-1)*16,(y-1)*16,x*16,y*16),
        image1.Canvas,rect(0,16*15,16,16*16));
  end;
end;

procedure Tmainfrm.bulei(a, b: Integer);
var
  i,n: Integer;
begin
  startarray;
  llei:=Point(0,0);
  mainfrm.ClientWidth:=16 * a+18;
  mainfrm.ClientHeight:=16 * b+59;
  lq.Picture.Bitmap.Width:=16*a;
  lq.Picture.Bitmap.Height:=16*b;
  for i:=1 to a do
    for n:=1 to b do
    begin
      lq.Canvas.CopyRect(rect((i-1)*16,(n-1)*16,i*16,n*16),
        image1.Canvas,rect(0,0,16,16));
    end;
end;

procedure Tmainfrm.leishu(s:integer);
var
  i,n,m,z:integer;
begin
  m:=1000;
  z:=0;
  if s<0 then
    z := z-s
  else
    z := s;
  for i:=1 to 3 do
  begin
    m:=Trunc(m/10);
    if m=0 then m:=1;
    n:=Trunc(z/m) mod 10;
    ls.Canvas.CopyRect(rect((i-1)*13,0,i*13,23),
      image2.Canvas,rect(0,23*(11-n),13,23*(12-n)));
  end;
  if s<0 then
    ls.Canvas.CopyRect(rect(0,0,13,23),
      image2.Canvas,rect(0,0,13,23));
end;

procedure Tmainfrm.shijian(s:integer);
var
  i,n,m:integer;
begin
  m:=1000;
  for i:=1 to 3 do
  begin
    m:=Trunc(m/10);
    if m=0 then m:=1;
    n:=Trunc(s/m) mod 10;
      ms.Canvas.CopyRect(rect((i-1)*13,0,i*13,23),
        image2.Canvas,rect(0,23*(11-n),13,23*(12-n)));
  end;
end;

procedure Tmainfrm.FormCreate(Sender: TObject);
begin
  xl:=9;
  yl:=9;
  lei:=10;
  imgstart.Canvas.CopyRect(rect(0,0,24,24),
    image3.Canvas,rect(0,24*4,24,24*5));
  leishu(lei);
  shijian(0);
  bulei(xl,yl);
end;

procedure Tmainfrm.imgstartMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  imgstart.Canvas.CopyRect(rect(0,0,24,24),
    image3.Canvas,rect(0,24*4,24,24*5));
  leishu(lei);
  shijian(0);
  bulei(xl,yl);
end;

procedure Tmainfrm.imgstartMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  imgstart.Canvas.CopyRect(rect(0,0,24,24),
    image3.Canvas,rect(0,0,24,24));
end;

procedure Tmainfrm.N4Click(Sender: TObject);
begin
  n4.Checked:=true;
  xl:=9;
  yl:=9;
  lei:=10;
  bulei(xl,yl);
  leishu(10);
  shijian(0);
end;

procedure Tmainfrm.N5Click(Sender: TObject);
begin
  n5.Checked:=true;
  xl:=16;
  yl:=16;
  lei:=40;
  bulei(xl,yl);
  leishu(lei);
  shijian(0);
end;

procedure Tmainfrm.N6Click(Sender: TObject);
begin
  n6.Checked:=true;
  xl:=30;
  yl:=16;
  lei:=99;
  bulei(xl,yl);
  leishu(lei);
  shijian(0);
end;

procedure Tmainfrm.N7Click(Sender: TObject);
begin
  n7.Checked:=true;
  form1.Edit1.Text:=inttostr(xl);
  form1.Edit2.Text:=inttostr(yl);
  form1.Edit3.Text:=inttostr(lei);
  Form1.ShowModal;
end;

procedure Tmainfrm.N12Click(Sender: TObject);
begin
  n12.Checked:=not n12.Checked;
end;

procedure Tmainfrm.N11Click(Sender: TObject);
begin
  close;
end;

procedure Tmainfrm.FormResize(Sender: TObject);
begin
  imgstart.Left:=round(t.Width/2-12);
  msp.Left:=t.Width - 49;
end;

procedure Tmainfrm.lqMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  imgstart.Canvas.CopyRect(rect(0,0,24,24),
    image3.Canvas,rect(0,24*3,24,24*4));
  if not (ssCtrl in shift) then
  begin
    if not(ssRight in shift) then
    if button=mbLeft then
      lqld(x,y);
    if not(ssLeft in shift) then
    if button=mbRight then
      lqrd(x,y);
    if (ssRight in shift) and (ssLeft in shift)
      or (button=mbMiddle) then
      lqmd(x,y);
  end
  else
    lqhelp(x,y);
end;

procedure Tmainfrm.lqMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  js.Enabled:=true;
  gameon:=true;
  llei:=point(0,0);
  imgstart.Canvas.CopyRect(rect(0,0,24,24),
    image3.Canvas,rect(0,24*4,24,24*5));
  if not (ssCtrl in shift) then
  begin
    if not(ssRight in shift) then
      if button=mbLeft then
        lqlu(x,y);
    if ((ssRight in shift) and (button=mbLeft))
      or ((ssLeft in shift) and (button=mbRight))
      or (button=mbMiddle) then
      lqmu(x,y);
  end;
end;

procedure Tmainfrm.lqMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if not (ssCtrl in shift) then
  begin
    if shift=[ssLeft] then
      lqlm(x,y);
    if ((ssRight in shift) and (ssLeft in shift))
      or (ssMiddle in shift) then
      lqmm(x,y);
  end;
end;

procedure Tmainfrm.N2Click(Sender: TObject);
begin
  shi:=0;
  leishu(lei);
  shijian(shi);
  bulei(xl,yl);
end;

procedure Tmainfrm.N14Click(Sender: TObject);
begin
  showmessage('自己重写的扫雷的程序!');
end;

procedure Tmainfrm.jsTimer(Sender: TObject);
begin
  inc(shi);
  shijian(shi);
end;

procedure Tmainfrm.FormActivate(Sender: TObject);
begin
  if gameon then
  js.Enabled:=true;
end;

procedure Tmainfrm.N15Click(Sender: TObject);
var
  a,b:integer;
begin
  if n15.Caption='查看(&L)'then
  begin
    for a:=1 to xl do
      for b:=1 to yl do
      begin
        if (not leik[a,b]) and (leif[a,b]=wulei) then
        begin
          if leion[a,b] = -1 then
          begin
            lq.Canvas.CopyRect(rect((a-1)*16,(b-1)*16,a*16,b*16),
              image1.Canvas,rect(0,16*5,16,16*6));
          end
          else
          begin
            lq.Canvas.CopyRect(rect((a-1)*16,(b-1)*16,a*16,b*16),
              image1.Canvas,rect(0,16*(15-leion[a,b]),16,16*(16-leion[a,b])));
          end;
        end;
      end;
    n15.Caption:='恢复(&R)';
  end
  else
  begin
    n15.Caption:='查看(&L)';
    for a:=1 to xl do
      for b:=1 to yl do
        if (not leik[a,b]) and (leif[a,b]=wulei) then
          lq.Canvas.CopyRect(rect((a-1)*16,(b-1)*16,a*16,b*16),
            image1.Canvas,rect(0,0,16,16));
  end;
end;

procedure Tmainfrm.N9Click(Sender: TObject);
begin
  if sd.Execute then
  mainfrm.GetFormImage.SaveToFile(sd.FileName);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -