BastatDoreau / Mbed 2 deprecated MoveYourTetris

Dependencies:   mbed APDS_9960 mbed-rtos

Dependents:   MoveYourTetris_OK

src/cMatrice.cpp

Committer:
Willheisen
Date:
2016-04-11
Revision:
14:6b6aa696680f
Parent:
13:336220ac9a8b
Child:
15:3782eb2bc312

File content as of revision 14:6b6aa696680f:

#include "cMatrice.h"
#include <algorithm>

// CONSTRUCTEURS

cMatrice::cMatrice()
{

}

cMatrice::cMatrice(unsigned char c, unsigned char l)
{
    _lig = l;
    _col = c;
    _matrice = new unsigned char*[_lig];
    for(unsigned char i = 0; i < _lig; i++) {
        _matrice[i] = new unsigned char[_col];
    }
    clear();
}

// DESTRUCTEUR
cMatrice::~cMatrice()
{
    for(unsigned char i = 0; i < _lig; i++) {
        delete[] _matrice[i];
        delete[] _matrice;
    }
}

// GETTER
unsigned char cMatrice::getValTab(unsigned char l, unsigned char c)
{
    return _matrice[l][c];
}

unsigned char cMatrice::getCol()
{
    return _col;
}

unsigned char cMatrice::getLig()
{
    return _lig;
}

cForme* cMatrice::get_pForme()
{
    return _pForme;
}
// SETTER

void cMatrice::setCol(unsigned char c)
{
    _col = c;
}

void cMatrice::setLig(unsigned char l)
{
    _lig = l;
}
void cMatrice::setValTab(unsigned char l, unsigned char c, unsigned char coul)
{
    _matrice [l][c] = coul;
}

// METHODES

//      Paramètres:
//  f: Forme à afficher
//  c: Couleur
void cMatrice::afficherForme(cForme* f, unsigned char c)
{
    _pForme = f;
    // Changement de couleur des Leds
    for (int i = 0; i < 4; i++) {
        _pForme->getLed(i).setCouleur(c);
        _matrice[_pForme->getLed(i).getPositionX()][_pForme->getLed(i).getPositionY()] = c;

    }
}


//      Description:
//  Nettoyage de la matrice, passage à 0 de la valeur de chaque Led
void cMatrice::clear()
{
    for(unsigned char i = 0; i < _lig; i++) {
        for(unsigned char j = 0; j < _col; j++) {
            _matrice[i][j] = LED_NOIR;
        }
    }
    _matrice[0][0] = LED_ROUGE;
}

void cMatrice::updateMatrice()
{
    // On éteint les leds de la pièce
    for (int i = 0; i < 4; i++) {
        _matrice[_pForme->getLed(i).getOldPositionX()][_pForme->getLed(i).getOldPositionY()] = LED_NOIR;
    }
    // Affichage de la nouvelle position
    afficherForme(_pForme, _pForme->getLed(0).getCouleur());
    ///////////////////////////////////////////////////////////////////////////////////////////////
    // Controle de la collision avec les bords
    ///////////////////////////////////////////////////////////////////////////////////////////////
}

unsigned char cMatrice::verificationMvt(unsigned char mvt)
{
    unsigned char result = 0;
    ///////////////////////////////////////////////
    /////////////////////////////////////
    switch(mvt) {
        case 'b': {
            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UNE LIGNE
            if(_pForme->getTypeForme() == 0) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                    //Et si la LED en dessous de la LED 3 est noire
                                    if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                        //alors on peut descendre la piece
                                        result = 1;
                                    }
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED en dessous de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                            //alors on peut descendre la piece
                            result = 1;
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                    //Et si la LED en dessous de la LED 3 est noire
                                    if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                        //alors on peut descendre la piece
                                        result = 1;
                                    }
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            result = 1;
                        }
                        break;
                    }
                }//fin switch
            }//fin if

            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UN CARRE
            if(_pForme->getTypeForme() == 1) {
                //Si la LED en dessous de la LED 2 est noire
                if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                    //Et si la LED en dessous de la LED 3 est noire
                    if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                        //alors on peut descendre la piece
                        result = 1;
                    }
                }
            }
            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UN Z
            if(_pForme->getTypeForme() == 2) {
                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED en dessous de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }

                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED en dessous de la LED 1 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                }
            }
            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UN T
            if(_pForme->getTypeForme() == 3) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED en dessous de la LED 2 est noire
                        if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }

                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED en dessous de la LED 1 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                }
            }
            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UN L
            if(_pForme->getTypeForme() == 4) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED en dessous de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX()][_pForme->getLed(2).getPositionY() + 1] == LED_NOIR) {
                                //Et si la LED en dessous de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX()][_pForme->getLed(3).getPositionY() + 1] == LED_NOIR) {
                                    //alors on peut descendre la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED en dessous de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX()][_pForme->getLed(0).getPositionY() + 1] == LED_NOIR) {
                            //Et si la LED en dessous de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX()][_pForme->getLed(1).getPositionY() + 1] == LED_NOIR) {
                                //alors on peut descendre la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                }
            }
            break;
        }
        //Pour translater une pièce vers la droite
        case 'd': {
            ///////////////////////////////////////////////////////////////////////////////////
            //POUR UNE LIGNE
            if(_pForme->getTypeForme() == 0) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED à droite de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                    //Et si la LED à droite de la LED 3 est noire
                                    if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                        //alors on peut translater la piece
                                        result = 1;
                                    }
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                    //Et si la LED à droite de la LED 3 est noire
                                    if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                        //alors on peut translater la piece
                                        result = 1;
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
            }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN CARRE
            if(_pForme->getTypeForme() == 1) {
                //Si la LED à droite de la LED 1 est noire
                if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                    //Et si la LED à droite de la LED 3 est noire
                    if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                        //alors on peut translater la piece
                        result = 1;
                    }
                }
            }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN Z
            if(_pForme->getTypeForme() == 2) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED à droite de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED à droite de la LED 1 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                }
            }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN T
            if(_pForme->getTypeForme() == 3) {

                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED à droite de la LED 2 est noire
                        if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }

                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 2 est noire
                                if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED à droite de la LED 1 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }

                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                }
            }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN L
            if(_pForme->getTypeForme() == 4) {
                switch(_pForme->getOrientation()) {
                        //En orientation de base:
                    case 1: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 2:
                    case 2: {
                        //Si la LED à droite de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 1 est noire
                            if(_matrice[_pForme->getLed(1).getPositionX() + 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED à droite de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() + 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à droite de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() + 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à droite de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() + 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                }//switch L
            }//if L
        
        break;
    }
    //Pour translater une pièce vers la gauche
case 'g': {
        ///////////////////////////////////////////////////////////////////////////////////
        //POUR UNE LIGNE
        if(_pForme->getTypeForme() == 0) {

            switch(_pForme->getOrientation()) {
                    //En orientation de base:
                case 1: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //alors on peut translater la piece
                        result = 1;
                    }
                    break;
                }
                //En orientation 2:
                case 2: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à gauche de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                    }
                    break;
                }
                //En orientation 3:
                case 3: {
                    //Si la LED à gauche de la LED 3 est noire
                    if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                        //alors on peut translater la piece
                        result = 1;
                    }
                    break;
                }
                //En orientation 4:
                case 4: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à gauche de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                    }
                    break;
                }
            }
        }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN CARRE
        if(_pForme->getTypeForme() == 1) {
            //Si la LED à gauche de la LED 0 est noire
            if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                //Et si la LED à gauche de la LED 2 est noire
                if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                    //alors on peut translater la piece
                    result = 1;
                }
            }
        }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN Z
        if(_pForme->getTypeForme() == 2) {

            switch(_pForme->getOrientation()) {
                    //En orientation de base:
                case 1: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 2 est noire
                        if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                    }
                    break;
                }
                //En orientation 2:
                case 2: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 2 est noire
                        if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                    }
                    break;
                }
                //En orientation 3:
                case 3: {
                    //Si la LED à gauche de la LED 1 est noire
                    if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                    }
                    break;
                }
                //En orientation 4:
                case 4: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                    }
                    break;
                }
            }
        }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN T
        if(_pForme->getTypeForme() == 3) {

            switch(_pForme->getOrientation()) {
                    //En orientation de base:
                case 1: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                    }
                    break;
                }
                //En orientation 2:
                case 2: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                    }
                    break;
                }
                //En orientation 3:
                case 3: {
                    //Si la LED à gauche de la LED 2 est noire
                    if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 3 est noire
                        if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }

                    }
                    break;
                }
                //En orientation 4:
                case 4: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                    }
                    break;
                }
            }
        }
///////////////////////////////////////////////////////////////////////////////////
//POUR UN L
        if(_pForme->getTypeForme() == 4) {
            switch(_pForme->getOrientation()) {
                    //En orientation de base:
                case 1: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //alors on peut translater la piece
                            result = 1;
                        }
                    }
                    break;
                }
                //En orientation 2:
                case 2: {
                    //Si la LED à gauche de la LED 0 est noire
                    if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                        //Et si la LED à gauche de la LED 2 est noire
                        if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 3 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //alors on peut translater la piece
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 3:
                    case 3: {
                        //Si la LED à gauche de la LED 0 est noire
                        if(_matrice[_pForme->getLed(0).getPositionX() - 1][_pForme->getLed(0).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                //Et si la LED à gauche de la LED 3 est noire
                                result = 1;
                            }
                        }
                        break;
                    }
                    //En orientation 4:
                    case 4: {
                        //Si la LED à gauche de la LED 1 est noire
                        if(_matrice[_pForme->getLed(1).getPositionX() - 1][_pForme->getLed(1).getPositionY()] == LED_NOIR) {
                            //Et si la LED à gauche de la LED 2 est noire
                            if(_matrice[_pForme->getLed(2).getPositionX() - 1][_pForme->getLed(2).getPositionY()] == LED_NOIR) {
                                //Et si la LED à gauche de la LED 3 est noire
                                if(_matrice[_pForme->getLed(3).getPositionX() - 1][_pForme->getLed(3).getPositionY()] == LED_NOIR) {
                                    //alors on peut translater la piece
                                    result = 1;
                                }
                            }
                        }
                        break;
                    }
                }//switch L
            }//if L
            }
            break;
        }
    }
    return result;
}