Te propongo este código...espero te sirva...
Código Delphi
[-]
Const
APos:Array[1..9] Of TPoint=((X:1; Y:1),(X:1;Y:2),(X:1;Y:3),(X:2;Y:1),(X:2;Y:2),(X:2;Y:3),(X:3;Y:1),(X:3;Y:2),(X:3;Y:3));
Size_Matriz=3;
type
TMatriz=array[1..Size_Matriz,1..Size_Matriz] of Integer;
var i, aux:Integer;
matriz:TMatriz;
no1, no2:Boolean;
Key:Integer;
function CheckHorizontal(Values:TMatriz; Key:Integer):Boolean;
var
i,j, Count:Integer;
begin
Result:=False;
for i := 1 to Size_Matriz do
begin
Count:=0;
for j:=1 to Size_Matriz do
begin
If Values[i,j]=Key then
Inc(Count);
end;
Result:=Count=Size_Matriz;
if Result then
Break;
end;
end;
function CheckVertical(Values:TMatriz; Key:Integer):Boolean;
var
i,j, Count:Integer;
begin
Result:=False;
for j := 1 to Size_Matriz do
begin
Count:=0;
for i:=1 to Size_Matriz do
begin
If Values[i,j]=Key then
Inc(Count);
end;
Result:=(Count=Size_Matriz);
if Result then
Break;
end;
end;
function CheckDiagonalPrincipal(Values:TMatriz; Key:Integer):Boolean;
var
i,j, Count:Integer;
begin
Result:=False;
Count :=0;
for i := 1 to Size_Matriz do
begin
If Values[i,i]=Key then
Inc(Count);
end;
Result:=(Count=Size_Matriz);
end;
function CheckDiagonalSecundaria(Values:TMatriz; Key:Integer):Boolean;
var
i,j, Count:Integer;
begin
Result:=False;
Count :=0;
j:=1;
for i := Size_Matriz downto 1 do
begin
If Values[i,j]=Key then
Inc(Count);
Inc(j);
end;
Result:=(Count=Size_Matriz);
end;
begin
aux:= aux+1;
if (aux mod 2 <> 0) then
begin
(Sender as TImage).Picture:= Self.Image1.Picture;
(Sender as TImage).Enabled:= False;
Key:=1;
end
else
begin
(Sender as TImage).picture:= Self.Image2.Picture;
(Sender as TImage).enabled:= False;
Key:=2;
end;
Matriz[ APos[Tag].X, APos[Tag].Y]:= Key;
For i := 248 downto 8 do
begin
sleep(1);
refresh;
shape1.Top:=i;
end;
if CheckHorizontal(matriz, Key) or
CheckVertical(Matriz, Key) or
CheckDiagonalPrincipal(Matriz, Key) Or
CheckDiagonalSecundaria(Matriz, Key) then
begin
showmessage('Gana ' + label2.Caption);
no1:=Key=1;
no2:=Key=2;
end;
Saludos cordiales