SharpShooter

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Obstacle.h

Committer:
jboettcher
Date:
2016-10-28
Revision:
6:7f8c3169483a
Parent:
5:f51cdddf541e
Child:
9:96a2e663994b

File content as of revision 6:7f8c3169483a:

class Obstacle
{
    int x1,x2,y1,y2;
    uLCD_4DGL uLCD;
    bool direction;

public:
    Obstacle(int x1, int x2, int y1, int y2, uLCD_4DGL uLCD);
    void drawObstacle();
    void move(int speed);
    void changeDirection();// need change direction when hitting wall
    void setDirection(bool direction);
};

Obstacle::Obstacle(int a, int b, int c, int d, uLCD_4DGL e) {
    x1 = a;
    x2 = b;
    y1 = c;
    y2 = d;
    this->uLCD = e;
}

void Obstacle::drawObstacle() {
    uLCD.filled_rectangle(x1,y1,x2,y2,0xFFFFFF);
}

void Obstacle::move(int speed) {
    if (direction==1) {
        x1 += speed;
        x2 += speed;
    }
    else {
        x1 -= speed;
        x2 -= speed;
    }
}

void Obstacle::changeDirection() {
    direction = !direction
}

void Obstacle::setDirection(bool a) {
    direction = a;
}