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:
- 32:029962133529
- Parent:
- 30:c647da947bd9
- Child:
- 33:a6f0be429ce0
--- a/src/cMatrice.cpp Thu Apr 21 13:25:08 2016 +0000
+++ b/src/cMatrice.cpp Fri Apr 22 06:29:56 2016 +0000
@@ -2,13 +2,14 @@
#include <algorithm>
// CONSTRUCTEURS
-
+// Constructeur par défaut
cMatrice::cMatrice()
{
_lig = 0;
_col = 0;
}
+//Constructeur qui crée une matrice de l lignes sur c colonnes
cMatrice::cMatrice(int l, int c)
{
_lig = l;
@@ -67,44 +68,53 @@
// METHODES
-// Paramètres:
-// f: Forme à afficher
-// c: Couleur
+//afficherForme: méthode qui "colle la pièce en cours" à la matrice
+// Entrées: f: Forme à afficher
+// c: Couleur
+// Sorties: aucune.
void cMatrice::afficherForme(cForme* f, unsigned int c)
{
+ //////////////////////
+ Serial pc(USBTX, USBRX);
+ //////////////////////////////////////////
_pForme = f;
// Changement de couleur des Leds
for (int i = 0; i < 4; i++) {
_pForme->getLed(i).setCouleur(c);
- _matrice[_pForme->getLed(i).getPositionY()][_pForme->getLed(i).getPositionX()] = c;
-
+ _matrice[_pForme->getLed(i).getPositionX()][_pForme->getLed(i).getPositionY()] = c;
+ /////////////////////////////////////
+ pc.printf("x: %d, y: %d\n", _pForme->getLed(i).getPositionX(), _pForme->getLed(i).getPositionY());
}
}
-// Description:
+
+//clear: méthode qui efface la matrice
+// Entrées: aucune.
+// Sorties: aucune.
// Nettoyage de la matrice, passage à 0 de la valeur de chaque Led
void cMatrice::clear()
{
for( int i = 0; i < _lig; i++) {
for( int j = 0; j < _col; j++) {
- _matrice[i][j] = LED_NOIR;
+ _matrice[j][i] = LED_NOIR;
}
}
//////////////////////////////////////////////////////////////////////////////////////
_matrice[0][0] = LED_ROUGE;
- //_matrice[8][0] = LED_ROUGE;
+ //_matrice[6][7] = LED_VERT;
+ //_matrice[5][12] = LED_BLEU_CLAIR;
}
+//updateMatrice: méthode qui éteint les LEDs correspondant à l'anceinne position de la pièce en cours
+// Entrées: aucune.
+// Sortie: aucune.
void cMatrice::updateMatrice()
{
// On éteint les leds de la pièce
for (int i = 0; i < 4; i++) {
- _matrice[_pForme->getLed(i).getOldPositionY()][_pForme->getLed(i).getOldPositionX()] = LED_NOIR;
+ _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
- ///////////////////////////////////////////////////////////////////////////////////////////////
}