Mini projet LOO

Dependencies:   mbed APDS_9960 mbed-rtos

Dependents:   MoveYourTetris_OK

Home du projet

src/cForme.cpp

Committer:
clementdoreau
Date:
2016-04-07
Revision:
10:9ef3f520ff6c
Parent:
9:6f3d8b714a59
Child:
11:c37922a0a915

File content as of revision 10:9ef3f520ff6c:

#include "cForme.h"

cForme::cForme()
{

}

cForme::~cForme()
{

}
// GETTERS

unsigned char cForme::getOrientation()
{
    return _orientation;
}

unsigned char cForme::getPositionX()
{
    return _positionX;
}

unsigned char cForme::getPositionY()
{
    return _positionY;
}

unsigned char cForme::getOldPositionX()
{
    return _oldPositionX;
}

unsigned char cForme::getOldPositionY()
{
    return _oldPositionY;
}

cLed &cForme::getLed(unsigned char i)
{
    return _Leds[i];
}

// SETTERS
void cForme::setOrientation(unsigned char orientation)
{
    _orientation = orientation;
}

void cForme::setPositionX(unsigned char x)
{
    _positionX = x;
}
void cForme::setPositionY(unsigned char y)
{
    _positionY = y;
}

void cForme::setOldPositionX(unsigned char x)
{
    _oldPositionX = x;
}

void cForme::setOldPositionY(unsigned char y)
{
    _oldPositionY = y;
}

// METHODES

//		Description:
//	Décalage d'1 case vers le bas
void cForme::deplacementBas()
{ 																
    for (unsigned char i = 0; i < 4; i++) {
        _Leds[i].setOldPositionY(_Leds[i].getPositionY());
        _Leds[i].setPositionY(_Leds[i].getPositionY() + 1);
    }
    setOldPositionY(getPositionY());
    setPositionY(getPositionY() + 1);
}

//		Description:
//	Décalage d'1 case vers la droite
void cForme::deplacementDroite()
{															
    for (unsigned char i = 0; i < 4; i++) {
        _Leds[i].setOldPositionX(_Leds[i].getPositionX());
        _Leds[i].setPositionX(_Leds[i].getPositionX() + 1);
    }
    setOldPositionX(getPositionX());
    setPositionX(getPositionX() + 1);
}

//		Description:
//	Décalage d'1 case vers la gauche
void cForme::deplacementGauche()
{																
    for (unsigned char i = 0; i < 4; i++) {
        _Leds[i].setOldPositionX(_Leds[i].getPositionX());
        _Leds[i].setPositionX(_Leds[i].getPositionX() - 1);
    }
    setOldPositionX(getPositionX());
    setPositionX(getPositionX() - 1);
}

void cForme::rotationHoraire() {}