Mini projet LOO

Dependencies:   mbed APDS_9960 mbed-rtos

Dependents:   MoveYourTetris_OK

Home du projet

Committer:
clementdoreau
Date:
Thu Apr 07 15:24:07 2016 +0000
Revision:
10:9ef3f520ff6c
Parent:
9:6f3d8b714a59
Child:
11:c37922a0a915
Optimisation du code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
clementdoreau 0:b2acac6abf2b 1 #include "cForme.h"
clementdoreau 0:b2acac6abf2b 2
Willheisen 9:6f3d8b714a59 3 cForme::cForme()
Willheisen 9:6f3d8b714a59 4 {
clementdoreau 7:4b283e36b147 5
clementdoreau 7:4b283e36b147 6 }
clementdoreau 7:4b283e36b147 7
Willheisen 9:6f3d8b714a59 8 cForme::~cForme()
Willheisen 9:6f3d8b714a59 9 {
clementdoreau 7:4b283e36b147 10
clementdoreau 7:4b283e36b147 11 }
clementdoreau 7:4b283e36b147 12 // GETTERS
clementdoreau 7:4b283e36b147 13
Willheisen 9:6f3d8b714a59 14 unsigned char cForme::getOrientation()
Willheisen 9:6f3d8b714a59 15 {
Willheisen 9:6f3d8b714a59 16 return _orientation;
clementdoreau 0:b2acac6abf2b 17 }
clementdoreau 0:b2acac6abf2b 18
Willheisen 9:6f3d8b714a59 19 unsigned char cForme::getPositionX()
Willheisen 9:6f3d8b714a59 20 {
Willheisen 9:6f3d8b714a59 21 return _positionX;
clementdoreau 7:4b283e36b147 22 }
clementdoreau 1:ab5f440f4156 23
Willheisen 9:6f3d8b714a59 24 unsigned char cForme::getPositionY()
Willheisen 9:6f3d8b714a59 25 {
Willheisen 9:6f3d8b714a59 26 return _positionY;
clementdoreau 0:b2acac6abf2b 27 }
clementdoreau 0:b2acac6abf2b 28
clementdoreau 10:9ef3f520ff6c 29 unsigned char cForme::getOldPositionX()
clementdoreau 10:9ef3f520ff6c 30 {
clementdoreau 10:9ef3f520ff6c 31 return _oldPositionX;
clementdoreau 10:9ef3f520ff6c 32 }
clementdoreau 10:9ef3f520ff6c 33
clementdoreau 10:9ef3f520ff6c 34 unsigned char cForme::getOldPositionY()
clementdoreau 10:9ef3f520ff6c 35 {
clementdoreau 10:9ef3f520ff6c 36 return _oldPositionY;
clementdoreau 10:9ef3f520ff6c 37 }
clementdoreau 10:9ef3f520ff6c 38
clementdoreau 10:9ef3f520ff6c 39 cLed &cForme::getLed(unsigned char i)
Willheisen 9:6f3d8b714a59 40 {
Willheisen 9:6f3d8b714a59 41 return _Leds[i];
clementdoreau 7:4b283e36b147 42 }
clementdoreau 7:4b283e36b147 43
clementdoreau 7:4b283e36b147 44 // SETTERS
Willheisen 9:6f3d8b714a59 45 void cForme::setOrientation(unsigned char orientation)
Willheisen 9:6f3d8b714a59 46 {
Willheisen 9:6f3d8b714a59 47 _orientation = orientation;
clementdoreau 1:ab5f440f4156 48 }
clementdoreau 1:ab5f440f4156 49
Willheisen 9:6f3d8b714a59 50 void cForme::setPositionX(unsigned char x)
Willheisen 9:6f3d8b714a59 51 {
Willheisen 9:6f3d8b714a59 52 _positionX = x;
clementdoreau 7:4b283e36b147 53 }
Willheisen 9:6f3d8b714a59 54 void cForme::setPositionY(unsigned char y)
Willheisen 9:6f3d8b714a59 55 {
Willheisen 9:6f3d8b714a59 56 _positionY = y;
clementdoreau 0:b2acac6abf2b 57 }
clementdoreau 0:b2acac6abf2b 58
clementdoreau 10:9ef3f520ff6c 59 void cForme::setOldPositionX(unsigned char x)
clementdoreau 10:9ef3f520ff6c 60 {
clementdoreau 10:9ef3f520ff6c 61 _oldPositionX = x;
clementdoreau 10:9ef3f520ff6c 62 }
clementdoreau 10:9ef3f520ff6c 63
clementdoreau 10:9ef3f520ff6c 64 void cForme::setOldPositionY(unsigned char y)
clementdoreau 10:9ef3f520ff6c 65 {
clementdoreau 10:9ef3f520ff6c 66 _oldPositionY = y;
clementdoreau 10:9ef3f520ff6c 67 }
clementdoreau 10:9ef3f520ff6c 68
clementdoreau 7:4b283e36b147 69 // METHODES
clementdoreau 7:4b283e36b147 70
clementdoreau 7:4b283e36b147 71 // Description:
clementdoreau 7:4b283e36b147 72 // Décalage d'1 case vers le bas
Willheisen 9:6f3d8b714a59 73 void cForme::deplacementBas()
clementdoreau 10:9ef3f520ff6c 74 {
Willheisen 9:6f3d8b714a59 75 for (unsigned char i = 0; i < 4; i++) {
clementdoreau 10:9ef3f520ff6c 76 _Leds[i].setOldPositionY(_Leds[i].getPositionY());
Willheisen 9:6f3d8b714a59 77 _Leds[i].setPositionY(_Leds[i].getPositionY() + 1);
Willheisen 9:6f3d8b714a59 78 }
clementdoreau 10:9ef3f520ff6c 79 setOldPositionY(getPositionY());
Willheisen 9:6f3d8b714a59 80 setPositionY(getPositionY() + 1);
clementdoreau 0:b2acac6abf2b 81 }
clementdoreau 0:b2acac6abf2b 82
Willheisen 9:6f3d8b714a59 83 // Description:
Willheisen 9:6f3d8b714a59 84 // Décalage d'1 case vers la droite
Willheisen 9:6f3d8b714a59 85 void cForme::deplacementDroite()
clementdoreau 10:9ef3f520ff6c 86 {
Willheisen 9:6f3d8b714a59 87 for (unsigned char i = 0; i < 4; i++) {
clementdoreau 10:9ef3f520ff6c 88 _Leds[i].setOldPositionX(_Leds[i].getPositionX());
Willheisen 9:6f3d8b714a59 89 _Leds[i].setPositionX(_Leds[i].getPositionX() + 1);
Willheisen 9:6f3d8b714a59 90 }
clementdoreau 10:9ef3f520ff6c 91 setOldPositionX(getPositionX());
Willheisen 9:6f3d8b714a59 92 setPositionX(getPositionX() + 1);
Willheisen 9:6f3d8b714a59 93 }
clementdoreau 0:b2acac6abf2b 94
Willheisen 9:6f3d8b714a59 95 // Description:
Willheisen 9:6f3d8b714a59 96 // Décalage d'1 case vers la gauche
Willheisen 9:6f3d8b714a59 97 void cForme::deplacementGauche()
clementdoreau 10:9ef3f520ff6c 98 {
Willheisen 9:6f3d8b714a59 99 for (unsigned char i = 0; i < 4; i++) {
clementdoreau 10:9ef3f520ff6c 100 _Leds[i].setOldPositionX(_Leds[i].getPositionX());
Willheisen 9:6f3d8b714a59 101 _Leds[i].setPositionX(_Leds[i].getPositionX() - 1);
Willheisen 9:6f3d8b714a59 102 }
clementdoreau 10:9ef3f520ff6c 103 setOldPositionX(getPositionX());
Willheisen 9:6f3d8b714a59 104 setPositionX(getPositionX() - 1);
Willheisen 9:6f3d8b714a59 105 }
clementdoreau 7:4b283e36b147 106
Willheisen 9:6f3d8b714a59 107 void cForme::rotationHoraire() {}