SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Bullet.h
- Committer:
- jboettcher
- Date:
- 2016-10-31
- Revision:
- 15:e09ab0d14d4b
- Parent:
- 12:2f358065ba3f
File content as of revision 15:e09ab0d14d4b:
extern uLCD_4DGL uLCD;
extern Mutex mutex;
struct BulletLocation {
int x, topY, bottomY;
};
class Bullet {
int x, topY, bottomY;
int length;
int speed;
public:
Bullet();
void drawBullet(int x, int bottomY);
void eraseBullet();
void move();
BulletLocation getLocation();
};
Bullet::Bullet() {
length = 3;
speed = 3;
x=1;
topY=2;
bottomY=3;
}
void Bullet::drawBullet(int x2, int bottomY2) {
x = x2;
bottomY = bottomY2;
topY = bottomY + length;
mutex.lock();
uLCD.line(x,topY,x,bottomY, BLACK);
mutex.unlock();
}
void Bullet::move() {
Bullet::eraseBullet();
bottomY -= speed;
Bullet::drawBullet(x, bottomY);
}
void Bullet::eraseBullet() {
mutex.lock();
uLCD.line(x,topY,x,bottomY, BACKGROUND);
mutex.unlock();
}
BulletLocation Bullet::getLocation() {
BulletLocation coor {x, topY, bottomY};
return coor;
}
