SharpShooter

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

Obstacle.h

Committer:
jboettcher
Date:
2016-10-28
Revision:
11:55b65415b6ba
Parent:
9:96a2e663994b
Child:
12:2f358065ba3f

File content as of revision 11:55b65415b6ba:

extern uLCD_4DGL uLCD;


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

public:
    Obstacle(int x1, int x2, int y1, int y2);
    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) {
    x1 = a;
    x2 = b;
    y1 = c;
    y2 = d;
}

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;
}