سلامی مجدد
من برنامه بازی ساده xo ده در ده را نوشتم ولی الان برنامه دلفی را در دسترس ندارم دوستان خواهشا این سورس را ببیند و مشکلاتشو درست کنند و ارور هایش را بگیرند و اینجا سورس برنامهی درست را بنویسند
سورس:unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, jpeg, ExtCtrls;

type
TForm1 = class(TForm)
btnApply: TButton;
img: TImage;
rbX: TRadioButton;
rbO: TRadioButton;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
Edit1: TEdit;
procedure btnApplyClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure imgClick(Sender: TObject);
private
{ Private declarations }
function control(hint:string):boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses StrUtils;

{$R *.dfm}

procedure TForm1.btnApplyClick(Sender: TObject);
var
img: TImage;
begin
img :=TImage.Create(self);
img.Picture.LoadFromFile('z:\f.jpg');
img.Left:= 50;
img.Top:= 100;
img.Parent:= self;
img.Visible:= true;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
i,j:integer;
begin
for j:=0 to 9 do
begin
for i:=0 to 9 do
begin
with TImage.Create(self) do
begin
Picture.LoadFromFile('I:\xo\'+IntToStr(0)+'.jpg');
Parent:= Panel1;
Left:=(i*41)+1;
Top:=(j*26)+1;
Height:=25;
Width:=41;
Stretch:= false;
name:= 'img'+ IntToStr(j)+IntToStr(i);
Hint:= '0'+inttostr(i)+inttostr(j);
ShowHint:= true;
OnClick:= imgClick;
end;
end;

end;

end;
function TForm1.control(hint: string): boolean;
var
typ:integer;
str:string;
i,j:integer;
rtrn: boolean;
begin
rtrn:=false;
typ := strtoint( AnsiLeftStr(hint,1));
i:= strtoint(AnsiMidStr(hint,2,1));
j:=strtoint(AnsiRightStr(hint,1));
if (Timage(inttostr(typ)+inttostr(i-1)+inttostr(j))<>nil) then
if (Timage(inttostr(typ)+inttostr(i-2)+inttostr(j))<>nil) then
rtrn:= true;

if (Timage(inttostr(typ)+inttostr(i+1)+inttostr(j))<> nil) then
if (Timage(inttostr(typ)+inttostr(i+2)+inttostr(j))<> nil) then
rtrn:= true;


if (Timage(inttostr(typ)+inttostr(i)+inttostr(j-1))<>nil) then
if (Timage(inttostr(typ)+inttostr(i)+inttostr(j -2))<>nil) then
rtrn:=true;

if (Timage(inttostr(typ)+intostr(i)+inttostr(j+1))<>n il) then
if (Timage(inttostr(typ)+inttostr(i)+inttostr(j+2))<> nil) then
rtrn:=true;



if (Timage(inttostr(typ)+intostr(i-1)+inttostr(j-1))<>nil) then
if (Timage(inttostr(typ)+inttostr(i-2)+inttostr(j-2))<>nil) then
rtrn:=true;


if (Timage(inttostr(typ)+intostr(i+1)+inttostr(j+1))< >nil) then
if (Timage(inttostr(typ)+inttostr(i+2)+inttostr(j+2)) <>nil) then
rtrn:=true;


if (Timage(inttostr(typ)+intostr(i+1)+inttostr(j-1))<>nil) then
if (Timage(inttostr(typ)+inttostr(i+2)+inttostr(j-2))<>nil) then
rtrn:=true;


if (Timage(inttostr(typ)+intostr(i-1)+inttostr(j+1))<>nil) then
if (Timage(inttostr(typ)+inttostr(i-1)+inttostr(j+2))<>nil) then
rtrn:=true;



if (rtrn=true) then
begin

break;

ShowMessage(inttostr(typ)+'is a winner');
end;

ShowMessage(BoolToStr(rtrn));
Result:= rtrn;


end;

procedure TForm1.imgClick(Sender: TObject);
var
typ:integer;
str:string;
j:integer;
i,c: Integer;
st: string;
begin
typ := strtoint( AnsiLeftStr(TImage(Sender).Hint,1));
i:= strtoint(AnsiMidStr(TImage(Sender).Hint,2,1));
j:=strtoint(AnsiRightStr(TImage(Sender).Hint,1));
if typ=0 then
begin
if rbX.Checked then
begin
TImage(Sender).Picture.LoadFromFile('I:\xo\2.jpg') ;
TImage(Sender).Hint:=inttostr(2)+IntToStr(i)+IntTo Str(j);
rbX.Checked:=false;
rbO.Checked:=true;

end
else
begin
TImage(Sender).Picture.LoadFromFile('I:\xo\1.jpg') ;
TImage(Sender).Hint:=inttostr( 1)+IntToStr(i)+IntToStr(j);
rbX.Checked:=true;
rbO.Checked:=false;
end;
end;
control(TImage(Sender).Hint);
end;








end.