5,386
社区成员
发帖
与我相关
我的任务
分享
数据是数据,界面操作是界面操作不要混在一起。
TDiLei =class
DL:Boolean;//是不有地雷
State:Integer;//0 没用操作 1 插旗,2 问号 3 爆炸
end;
在定义一个棋盘类
TQiPan=class
RowCount:Integer;//地雷几行几列
ColCount:Integer;
AList:Array of TDiLei;//创建一个数组,保存的地雷
public
procedure SetState(Row,Col:Integer;State:Integer);//设置给定位置的地雷状态
function GetState(Row,Col:Integer):Integer;//得到给定位置的地雷状态
procedure Resetting(IsEnd:Boolean=false) ;//重置 IsEnd=True 设置为开始状态,否则设置为结束状态
end;
//绘制棋盘类
TQiPanDraw=class(TComponent)
Canvas:TCanvas;//要绘制的 画布
Width:Integer;
Heigth:Integer;
public
procedure Draw(QiPan:TQiPan);//绘制,根据给定的棋盘数据
procedure OnClick(Sender:TObject);//在单击事件中根据位置确定点了那个地雷,在根据地雷状态在变换状态,然后在重画画布
end;