Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Coloboración Paypal con ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 28-03-2013
cloayza cloayza is offline
Miembro
 
Registrado: may 2003
Ubicación: San Pedro de la Paz, Chile
Posts: 948
Poder: 25
cloayza Tiene un aura espectacularcloayza Tiene un aura espectacular
Te propongo este código...espero te sirva...

Código Delphi [-]
{
APos[Tag].X  =>Indice de la matriz
APos[Tag].Y  =>Indice de la matriz

Tag  Posicion Matriz
--------------------
1  =>matriz [1,1]
2  =>matriz [1,2]
3  =>matriz [1,3]
4  =>matriz [2,1]
5  =>matriz [2,2]
6  =>matriz [2,3]
7  =>matriz [3,1]
8  =>matriz [3,2]
9  =>matriz [3,3]

matriz [ APos[Tag].X, APos[Tag].Y ]
}

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));
    {APos Vector con las coordenadas de x e y de la matriz...}
    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
               { i,i coordenadas de la diagonal principal 1,1   2,2   3,3 }
               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
               { i,j coordenadas de la diagonal secundaria 3,1   2,2   1,3 }
               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;

     //Asignas el valor 1 o 2 que esta en la Variable KEY (Integer)...
     Matriz[ APos[Tag].X, APos[Tag].Y]:= Key;

     For i := 248 downto 8 do
     begin
          sleep(1);
          refresh;
          shape1.Top:=i;
     end;

     //Check el valor de la matriz de acuerdo a el valor de Key
     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
Responder Con Cita
  #2  
Antiguo 29-03-2013
Neg90 Neg90 is offline
Miembro
NULL
 
Registrado: mar 2013
Posts: 29
Poder: 0
Neg90 Va por buen camino
Muchas gracias por tu ayuda, ya esta andando perfecto el tateti, gracias por la explicación!
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro


La franja horaria es GMT +2. Ahora son las 14:19:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi