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

📄 lbend.pas

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

interface
type
  Tlbend = 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 Tlbend.Create;
begin
  FX := 4;
  FY := 0;
  FStatus := 0;
  if not IsOver then
    Draw;
end;

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

function Tlbend.Drop: Boolean;
begin
  if (FStatus = 0) then
  begin
    if FY >= 18 then
    begin
      Result := False;
    end
    else if (BG[FX, FY + 1] = 0) and (BG[FX + 1, FY + 2] = 0) and (BG[FX + 2, FY + 2] = 0) then
    begin
      FY := FY + 1;
      Draw;
      Result := True;
    end
    else
      Result := False;
    if not Result then
    begin
      BG[FX, FY] := 6;
      BG[FX + 1, FY] := 6;
      BG[FX + 1, FY + 1] := 6;
      BG[FX + 2, FY + 1] := 6;
    end;
  end
  else
  begin
    if FY >= 17 then
    begin
      Result := False;
    end
    else if (BG[FX, FY + 3] = 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 + 1, FY] := 6;
      BG[FX, FY + 1] := 6;
      BG[FX + 1, FY + 1] := 6;
      BG[FX, FY + 2] := 6;
    end;
  end;
end;

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

procedure Tlbend.Draw;
begin
  FillChar(FG, 200, #0);
  if (FStatus = 0) then
  begin
    FG[Fx, 0 + Fy] := 6;
    FG[Fx + 1, Fy] := 6;
    FG[Fx + 1, 1 + Fy] := 6;
    FG[Fx + 2, 1 + Fy] := 6;
  end
  else
  begin
    FG[Fx + 1, Fy] := 6;
    FG[Fx + 1, Fy + 1] := 6;
    FG[Fx, Fy + 1] := 6;
    FG[Fx, Fy + 2] := 6;
  end;
end;

procedure Tlbend.Rotate;
begin
  case FStatus of
    0: if (FY < 19) then
      begin
        if (BG[FX, FY + 1] = 0) and (BG[FX, FY + 2] = 0) then
        begin
          FStatus := 1;
        end;
      end;
    1: if (FX < 8) then
      begin
        if (BG[FX, FY] = 0) and (BG[FX + 2, FY + 1] = 0) then
        begin
          FStatus := 0;
        end;
      end;
  end;
  Draw;
end;

end.

⌨️ 快捷键说明

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