大侠们。有个delphi的游戏程序 代码看得不大懂 想请大侠们帮我写下注释。附上程序代码和运行界面。
unituMain;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,F...
unit uMain;interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, uEls, Spin, Buttons;
type TfrmMain = class(TForm) btnStart: TSpeedButton; Panel1: TPanel; Timer: TTimer; Panel3: TPanel; Panel2: TPanel; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure btnStartClick(Sender: TObject); procedure TimerTimer(Sender: TObject); private FEls: TEls; { Private declarations } public { Public declarations } end;
var frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);begin FEls.Free;end;
procedure TfrmMain.FormCreate(Sender: TObject);begin FEls := TEls.Create(Panel1, Panel2, Timer);end;
procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin case Key of VK_LEFT: FEls.MoveLeft; VK_RIGHT: FEls.MoveRight; VK_UP: FEls.Transform; VK_DOWN: FEls.MoveDown; else end;end;
procedure TfrmMain.btnStartClick(Sender: TObject);begin FEls.Start;end;
procedure TfrmMain.TimerTimer(Sender: TObject);begin FEls.MoveDown;end;
end. 展开
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, uEls, Spin, Buttons;
type TfrmMain = class(TForm) btnStart: TSpeedButton; Panel1: TPanel; Timer: TTimer; Panel3: TPanel; Panel2: TPanel; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure btnStartClick(Sender: TObject); procedure TimerTimer(Sender: TObject); private FEls: TEls; { Private declarations } public { Public declarations } end;
var frmMain: TfrmMain;
implementation
{$R *.dfm}
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);begin FEls.Free;end;
procedure TfrmMain.FormCreate(Sender: TObject);begin FEls := TEls.Create(Panel1, Panel2, Timer);end;
procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);begin case Key of VK_LEFT: FEls.MoveLeft; VK_RIGHT: FEls.MoveRight; VK_UP: FEls.Transform; VK_DOWN: FEls.MoveDown; else end;end;
procedure TfrmMain.btnStartClick(Sender: TObject);begin FEls.Start;end;
procedure TfrmMain.TimerTimer(Sender: TObject);begin FEls.MoveDown;end;
end. 展开
展开全部
这么清晰的代码,看不懂?真不知道怎么注释
首先FEls: TEls;是声明一个TEIs,TEIs是封装好的的一个类,就是游戏操作画面,它本身封装好了如下函数:
FEls.Start;//游戏开始
FEls.MoveLeft;//控制向左移动
FEls.MoveRight;//控制向右移动
FEls.MoveDown;//控制向下移动
FEls.Transform;//控制变换方向
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FEls.Free;//释放
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
FEls := TEls.Create(Panel1, Panel2, Timer);//实例化TEls,创建游戏操作画面,容器为Panel1和Panel2,定时器用Timer
end;
procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
//监听键盘消息,按下方向键响应类中不同方法
case Key of
VK_LEFT: FEls.MoveLeft;//按下向左键,控制向左移动
VK_RIGHT: FEls.MoveRight;//按下向右键,控制向右移动
VK_UP: FEls.Transform;//按下向上键,控制变换方向
VK_DOWN: FEls.MoveDown;//按下向下键,控制向下移动
else
end;
end;
procedure TfrmMain.btnStartClick(Sender: TObject);
begin
FEls.Start;//游戏开始
end;
procedure TfrmMain.TimerTimer(Sender: TObject);
begin
FEls.MoveDown;//定时器中,控制向下移动
end;
end.
首先FEls: TEls;是声明一个TEIs,TEIs是封装好的的一个类,就是游戏操作画面,它本身封装好了如下函数:
FEls.Start;//游戏开始
FEls.MoveLeft;//控制向左移动
FEls.MoveRight;//控制向右移动
FEls.MoveDown;//控制向下移动
FEls.Transform;//控制变换方向
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
FEls.Free;//释放
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
FEls := TEls.Create(Panel1, Panel2, Timer);//实例化TEls,创建游戏操作画面,容器为Panel1和Panel2,定时器用Timer
end;
procedure TfrmMain.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
//监听键盘消息,按下方向键响应类中不同方法
case Key of
VK_LEFT: FEls.MoveLeft;//按下向左键,控制向左移动
VK_RIGHT: FEls.MoveRight;//按下向右键,控制向右移动
VK_UP: FEls.Transform;//按下向上键,控制变换方向
VK_DOWN: FEls.MoveDown;//按下向下键,控制向下移动
else
end;
end;
procedure TfrmMain.btnStartClick(Sender: TObject);
begin
FEls.Start;//游戏开始
end;
procedure TfrmMain.TimerTimer(Sender: TObject);
begin
FEls.MoveDown;//定时器中,控制向下移动
end;
end.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询