Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed APDS_9960 mbed-rtos
Diff: src/cMatrice.cpp
- Revision:
- 12:7afdbc7465ac
- Parent:
- 11:c37922a0a915
- Child:
- 13:336220ac9a8b
--- a/src/cMatrice.cpp Sun Apr 10 17:46:03 2016 +0000 +++ b/src/cMatrice.cpp Sun Apr 10 20:51:02 2016 +0000 @@ -103,112 +103,797 @@ /////////////////////////////////////////////////////////////////////////////////////////////// } -unsigned char cMatrice::verificationMvt(unsigned char c) +unsigned char cMatrice::verificationMvt(unsigned char mvt) { unsigned char result = 0; + /////////////////////////////////////////////// + ///////////////////////////////////// Serial pc(USBTX, USBRX); - /*unsigned char position[4][2]= {0}; - unsigned char positionXMin = 7; - unsigned char positionXMax = 0; - unsigned char positionYMax = 0; - //on cherche la coordonnées de la/les LED(s) de la pièce la/les plus basse(s) - for (int i = 0; i < 4; i++) { - if(_pForme->getLed(i).getPositionX() > position[i][0]) { - position[i][0] = _pForme->getLed(i).getPositionX(); - } - if(_pForme->getLed(i).getPositionY() > position[i][1]) { - position[i][1] = _pForme->getLed(i).getPositionY(); - } - } + switch(mvt) { + case 'b': { + /////////////////////////////////////////////////////////////////////////////////// + //POUR UNE LIGNE + if(_pForme->getTypeForme() == 0) { - for (int i = 0; i < 4; i++) { - if(position[i][0] > positionXMax) { - positionXMax = position[i][0]; - } else if(position[i][0] < positionXMin) { - positionXMin = position[i][0]; - } - if (position[i][1] > positionYMax) { - positionYMax = position[i][1]; - } - } - pc.printf("Xmin= %d, Xmax= %d, Ymax = %d \n", positionXMin, positionXMax, positionYMax); - */ - //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 + 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; } - } - 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) { + //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; + } } - 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; + } + } } - //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 +/////////////////////////////////////////////////////////////////////////////////// +//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; } - 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; + } } - //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; + } +/////////////////////////////////////////////////////////////////////////////////// +//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; } - 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; + } } - - pc.printf("%d\n", result); - - - - - /* switch(c) { - //si c'est un déplacement vers le bas - case 'b': { - if( - break; - } - - }*/ return result; -} +} \ No newline at end of file