Ver Mensaje Individual
  #6  
Antiguo 15-11-2006
dany2006 dany2006 is offline
Miembro
 
Registrado: nov 2006
Posts: 18
Reputación: 0
dany2006 Va por buen camino
Respuesta

CLARO Q SI. CUANDO TERMINE EL JUEGUITO LO MANDO COMPLETO PARA Q SE ENTIENDA MEJOR.
Código Delphi [-]
void TForm1::calculo_grupo(){
    if (vecinos_examinados==0) {
        grupo->Cols[0]->Clear();
        grupo->Cols[1]->Clear();
        grupo->Cells[0][0]=IntToStr(X);
        grupo->Cells[1][0]=IntToStr(Y);
    }
    if (X+1<=10)
    if (matriz_color->Cells[X][Y]==matriz_color->Cells[X+1][Y]) {
        bool repetido=false;
        for (int i=0; i <= 20; i++) {
            if ( (grupo->Cells[0][i]==IntToStr(X+1)) &&
                 (grupo->Cells[1][i]==IntToStr(Y)) ){
                        repetido=true;
            }
        }
        if (repetido==false) {
            cant_vecinos++;
            grupo->Cells[0][cant_vecinos]=IntToStr(X+1);
            grupo->Cells[1][cant_vecinos]=IntToStr(Y);
        }
    }
    if (X-1>=0)
    if (matriz_color->Cells[X][Y]==matriz_color->Cells[X-1][Y]) {
        bool repetido=false;
        for (int i=0; i <= 20; i++) {
            if ( (grupo->Cells[0][i]==IntToStr(X-1)) &&
                 (grupo->Cells[1][i]==IntToStr(Y)) ){
                        repetido=true;
            }
        }
        if (repetido==false) {
            cant_vecinos++;
            grupo->Cells[0][cant_vecinos]=IntToStr(X-1);
            grupo->Cells[1][cant_vecinos]=IntToStr(Y);
        }
    }
    if (Y+1<=10)
    if (matriz_color->Cells[X][Y]==matriz_color->Cells[X][Y+1]) {
        bool repetido=false;
        for (int i=0; i <= 20; i++) {
            if ( (grupo->Cells[0][i]==IntToStr(X)) &&
                 (grupo->Cells[1][i]==IntToStr(Y+1)) ){
                        repetido=true;
            }
        }
        if (repetido==false) {
            cant_vecinos++;
            grupo->Cells[0][cant_vecinos]=IntToStr(X);
            grupo->Cells[1][cant_vecinos]=IntToStr(Y+1);
        }
    }
    if (Y-1>=0)
    if (matriz_color->Cells[X][Y]==matriz_color->Cells[X][Y-1]) {
        bool repetido=false;
        for (int i=0; i <= 20; i++) {
            if ( (grupo->Cells[0][i]==IntToStr(X)) &&
                 (grupo->Cells[1][i]==IntToStr(Y-1)) ){
                        repetido=true;
            }
        }
        if (repetido==false) {
            cant_vecinos++;
            grupo->Cells[0][cant_vecinos]=IntToStr(X);
            grupo->Cells[1][cant_vecinos]=IntToStr(Y-1);
        }
    }
    if (cant_vecinos>0 && cant_vecinos>vecinos_examinados) {
        vecinos_examinados++;
        X=StrToInt(grupo->Cells[0][vecinos_examinados]);
        Y=StrToInt(grupo->Cells[1][vecinos_examinados]);
        calculo_grupo();
    }
}

Última edición por vtdeleon fecha: 18-11-2006 a las 22:50:44.
Responder Con Cita