SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Diff: Shooter.h
- Revision:
- 12:2f358065ba3f
- Parent:
- 11:55b65415b6ba
- Child:
- 15:e09ab0d14d4b
diff -r 55b65415b6ba -r 2f358065ba3f Shooter.h --- a/Shooter.h Fri Oct 28 20:07:38 2016 +0000 +++ b/Shooter.h Sat Oct 29 00:18:10 2016 +0000 @@ -1,4 +1,5 @@ extern uLCD_4DGL uLCD; +extern Mutex mutex; class Shooter { @@ -10,6 +11,7 @@ void eraseShooter(); void moveLeft(); void moveRight(); + int getLocation(); }; Shooter::Shooter() { @@ -17,26 +19,38 @@ } void Shooter::drawShooter() { - uLCD.triangle(x, 115, x-5, 125, x-5, 125, 0x3300ff); + mutex.lock(); + uLCD.triangle(x, 115, x-5, 125, x+5, 125, BLUE); + uLCD.triangle(x, 118, x-2, 123, x+2, 123, BLUE); + mutex.unlock(); } void Shooter::eraseShooter() { - uLCD.triangle(x, 115, x-5, 125, x-5, 125, 0x000000); + mutex.lock(); + uLCD.filled_rectangle(0, 115, 127, 127, BACKGROUND); + mutex.unlock(); } void Shooter::moveLeft() { - eraseShooter(); - if (x==64) x = 32; - if (x==96) x = 64; - drawShooter(); + if (x==24) return; + mutex.lock(); + Shooter::eraseShooter(); + if (x==64) x = 24; + if (x==104) x = 64; + Shooter::drawShooter(); + mutex.unlock(); } void Shooter::moveRight() { - eraseShooter(); - if (x==64) x = 96; - if (x==32) x = 64; - drawShooter(); + if (x==104) return; + mutex.lock(); + Shooter::eraseShooter(); + if (x==64) x = 104; + if (x==24) x = 64; + Shooter::drawShooter(); + mutex.unlock(); } - - \ No newline at end of file +int Shooter::getLocation() { + return x; +} \ No newline at end of file