SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Diff: Bullet.h
- Revision:
- 12:2f358065ba3f
- Parent:
- 11:55b65415b6ba
- Child:
- 15:e09ab0d14d4b
--- a/Bullet.h Fri Oct 28 20:07:38 2016 +0000 +++ b/Bullet.h Sat Oct 29 00:18:10 2016 +0000 @@ -1,4 +1,5 @@ extern uLCD_4DGL uLCD; +extern Mutex mutex; struct BulletLocation { int x, topY, bottomY; @@ -34,20 +35,27 @@ this->uLCD = uLCD; }*/ -void Bullet::drawBullet(int x, int bottomY) { - this->x = x; - this->bottomY = bottomY; - this->topY = bottomY + length; - uLCD.line(x,topY,x,bottomY, 0xFFFFFF); +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() { - bottomY+= speed; - drawBullet(x, bottomY); + Bullet::eraseBullet(); + bottomY -= speed; + Bullet::drawBullet(x, bottomY); } void Bullet::eraseBullet() { - uLCD.line(x,topY,x,bottomY, 0x000000); + mutex.lock(); + uLCD.line(x,topY,x,bottomY, BACKGROUND); + mutex.unlock(); + } BulletLocation Bullet::getLocation() {