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

📄 mychangebrick.pas

📁 delphi俄罗斯方块delphi俄罗斯方块
💻 PAS
字号:
unit myChangeBrick;

interface

uses
  Classes,myData,Dialogs,SysUtils;

type
  TChangeBrick = class(TThread)
  private
    { Private declarations }
  protected
    procedure Execute; override;
  end;

implementation
uses
  gm;
{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure TChangeBrick.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ TChangeBrick }

procedure TChangeBrick.Execute;
var
  bufBrick:TMatrixData;
  buf,aflag:integer;
begin
  bufBrick:=gmForm.curBrick; //copy gmForm.curBrick to a buffer
  buf:=gmForm.curBrick.tag;
  aflag:=gmForm.curBrick.flag;
  case aflag of
  1,3,5:begin
      bufBrick.tag:=(bufBrick.tag+1)mod 2;
      SetMatrix2(bufBrick,aflag+buf,gmForm.curBrick.xIndex,gmForm.curBrick.yIndex);
    end;
  7,11,15:begin
      bufBrick.tag:=(bufBrick.tag+1)mod 4;
      SetMatrix2(bufBrick,aflag+buf,gmForm.curBrick.xIndex,gmForm.curBrick.yIndex);
    end;
  end;
  if OutLeftRange(bufBrick) then
  begin
    while OutLeftRange(bufBrick)do
      bufBrick.xIndex:=bufBrick.xIndex+1;
    if not(OutBottomRange(bufBrick)or OutRightRange(bufBrick)) then
      gmForm.curBrick:=bufBrick;
  end;
  if OutRightRange(bufBrick) then
  begin
    while OutRightRange(bufBrick)do
      bufBrick.xIndex:=bufBrick.xIndex-1;
    if not(OutBottomRange(bufBrick)or OutLeftRange(bufBrick)) then
      gmForm.curBrick:=bufBrick;
  end;
  if not(OutLeftRange(bufBrick) or OutRightRange(bufBrick) or OutBottomRange(bufBrick)) then
  begin
     gmForm.curBrick:=bufBrick;
  end;
  gmForm.Caption:=inttostr(random(100));
end;

end.

⌨️ 快捷键说明

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