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

📄 diamonds.pas

📁 是一个非常好的游戏
💻 PAS
字号:
unit diamonds;

interface
type
  TDiamonds = class
  public
    FStatus: Byte;
    FX, FY: Integer;
  public
    constructor Create;
    procedure Rotate;
    procedure Move(DX: Integer);
    function Drop: Boolean;
    procedure Draw;
    function IsOver: Boolean;
  end;
implementation
uses
  Main;

constructor TDiamonds.Create;
begin
  FX := 4;
  FY := 0;
  FStatus := 0;
  if not IsOver then
    Draw;
end;

function TDiamonds.IsOver: Boolean;
begin
  if (BG[FX, FY] <> 0) or (BG[FX + 1, FY] <> 0) or
    (BG[FX + 1, FY] <> 0) or (BG[FX + 1, FY + 1] <> 0) then
    Result := True
  else
    Result := False;
end;

function TDiamonds.Drop: Boolean;
begin
  if FY >= 18 then
  begin
    Result := False;
  end
  else if (BG[FX, FY + 2] = 0) and (BG[FX + 1, FY + 2] = 0) then
  begin
    FY := FY + 1;
    Draw;
    Result := True;
  end
  else
    Result := False;
  if not Result then
  begin
    BG[FX, FY] := 2;
    BG[FX, FY + 1] := 2;
    BG[FX + 1, FY] := 2;
    BG[FX + 1, FY + 1] := 2;
  end;
end;

procedure TDiamonds.Move(DX: Integer);
begin
  if (FX + DX >= 0) and (FX + DX <= 8) then
  begin
    if (BG[FX + DX, FY] = 0) and
      (BG[FX + DX, FY + 1] = 0) and
      (BG[FX + DX + 1, FY] = 0) and
      (BG[FX + DX + 1, FY + 1] = 0) then
      FX := FX + DX;
  end;
  Draw;
end;

procedure TDiamonds.Draw;
begin
  FillChar(FG, 200, #0);
  FG[Fx, 0 + Fy] := 2;
  FG[Fx, 1 + Fy] := 2;
  FG[Fx + 1, Fy] := 2;
  FG[Fx + 1, 1 + Fy] := 2;
end;

procedure TDiamonds.Rotate;
begin
{}
end;


end.

⌨️ 快捷键说明

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