各位大哥小弟我Delphi初学编程,还请各位帮个忙,我实在画不出算法流程图了.
还希望各位大哥帮忙写一下
分别有两个按钮: 发牌 洗牌
代码如下:
发牌
procedure TForm1.Button1Click(Sender: TObject);
var i: integer;
nSleep: integer;
Steps: integer;
BZ: integer;
begin
nSleep := 10;
Steps := 3;
BZ := 0;
try
My_Bmp := TBitmap.Create;
for i := 0 to 53 do
begin
My_Bmp.LoadFromResourceName(HInstance, 'CARD_' + IntToStr(Total_Card_Info[i]));
Move_Card(PB, PB.Width div 2, PB.Height div 2, Hand_Card_Info[0, i].X, Hand_Card_Info[0, i].Y, Card_Width, Card_Height, Back_ID, -1, BZ, nSleep, Steps);
PB.Canvas.Draw(Hand_Card_Info[0, i].X, Hand_Card_Info[0, i].Y, My_Bmp);
Hand_Card_Info[0, i].ID := Total_Card_Info[i];
Hand_Card_Info[0, i].Display_YesOrNo := True;
//减少中间的牌
Paint_Send_Middle_Card(PB, MotherCardBack_Rect, PB.Width div 2, 200, 54 - 1 - i, Card_Width, Card_Height, Back_ID, 54);
end;
finally
My_Bmp.Free;//所有牌显示
end;
showmessage('发牌结束')
end;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
T : TRect;
begin
MotherCardBack_Rect := TBitmap.Create ;
MotherCardBack_Rect.Width := PB.Width ;
MotherCardBack_Rect.height := PB.height ;
T := Rect(1,1,PB.Width ,PB.Height );
MotherCardBack_Rect.Canvas.CopyRect(T, PB.Canvas , T);
Card_Space_Card := 14; //发牌后的间距;
Side_Width := 15;
fix_X := 5; //发牌后的X坐标 ;
fix_Y := 15; //发牌后的Y坐标 ;
//初始化发牌的位置:
for i := 0 to 54 - 1 do
begin
Hand_Card_Info[0, i].X := fix_X;
Hand_Card_Info[0, i].Y := fix_Y;
fix_X := fix_X + Card_Space_Card;
end;
end;
洗牌
procedure TForm1.Button5Click(Sender: TObject);
begin
PB.Refresh;
sleep(500);
//洗牌
Wash_Card(Total_Card_Info);
Paint_Send_Middle_Card(PB, MotherCardBack_Rect, PB.Width div 2, 200, 54, Card_Width, Card_Height, Back_ID, 54);
showmessage('洗牌完毕,等待您发牌')
end;
小弟在此感激不尽了!!!