📄 custobj.pas
字号:
unit CustObj;
interface
uses
Stick, Diamonds, LBend, RBend, Tletter, LCrutch, RCrutch;
type
TCustObj = class
private
FStick: TStick;
FDiamonds: TDiamonds;
FTLetter: TTLetter;
FLCurtch: TLCurtch;
FRCurtch: TRCurtch;
FLBend: TLBend;
FRBend: TRBend;
public
FType: Integer;
constructor Create(aType: Integer);
destructor Destroy; override;
procedure Rotate;
procedure Move(DX: Integer);
function Drop: Boolean;
procedure Draw;
function IsOver: Boolean;
function ClearLine: Integer;
end;
implementation
uses
Main;
function TCustObj.ClearLine: Integer;
var
i, j, k, l, Count, Lines: Integer;
begin
Lines := 0;
for i := 0 to 19 do
begin
Count := 0;
for j := 0 to 9 do
begin
if BG[j, i] <> 0 then
Count := Count + 1;
end;
if Count = 10 then
begin
Inc(Lines);
for k := i - 1 downto 0 do
for l := 0 to 9 do
BG[l, k + 1] := BG[l, k];
for l := 0 to 9 do
BG[l, 0] := 0;
end;
end;
Result := Lines;
end;
function TCustObj.IsOver: Boolean;
begin
Result := False;
case FType of
1: Result := FStick.IsOver;
2: Result := FDiamonds.IsOver;
3: Result := FTLetter.IsOver;
4: Result := FLCurtch.IsOver;
5: Result := FRCurtch.IsOver;
6: Result := FLBend.IsOver;
7: Result := FRBend.IsOver;
end;
end;
constructor TCustObj.Create(aType: Integer);
begin
FType := aType + 1;
case FType of
1: FStick := TStick.Create;
2: FDiamonds := TDiamonds.Create;
3: FTLetter := TTLetter.Create;
4: FLCurtch := TLCurtch.Create;
5: FRCurtch := TRCurtch.Create;
6: FLBend := TLBend.Create;
7: FRBend := TRBend.Create;
end;
end;
destructor TCustObj.Destroy;
begin
case FType of
1: FStick.Free;
2: FDiamonds.Free;
3: FTLetter.Free;
4: FLCurtch.Free;
5: FRCurtch.Free;
6: FLBend.Free;
7: FRBend.Free;
end;
inherited;
end;
procedure TCustObj.Rotate;
begin
case FType of
1: FStick.Rotate;
2: FDiamonds.Rotate;
3: FTLetter.Rotate;
4: FLCurtch.Rotate;
5: FRCurtch.Rotate;
6: FLBend.Rotate;
7: FRBend.Rotate;
end;
end;
procedure TCustObj.Move(DX: Integer);
begin
case FType of
1: FStick.Move(DX);
2: FDiamonds.Move(DX);
3: FTLetter.Move(DX);
4: FLCurtch.Move(DX);
5: FRCurtch.Move(DX);
6: FLBend.Move(DX);
7: FRBend.Move(DX);
end;
end;
function TCustObj.Drop: Boolean;
begin
Result := False;
case FType of
1: Result := FStick.Drop;
2: Result := FDiamonds.Drop;
3: Result := FTLetter.Drop;
4: Result := FLCurtch.Drop;
5: Result := FRCurtch.Drop;
6: Result := FLBend.Drop;
7: Result := FRBend.Drop;
end;
end;
procedure TCustObj.Draw;
begin
case FType of
1: FStick.Draw;
2: FDiamonds.Draw;
3: FTLetter.Draw;
4: FLCurtch.Draw;
5: FRCurtch.Draw;
6: FLBend.Draw;
7: FRBend.Draw;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -