SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Shooter.h
- Committer:
- jboettcher
- Date:
- 2016-10-29
- Revision:
- 12:2f358065ba3f
- Parent:
- 11:55b65415b6ba
- Child:
- 15:e09ab0d14d4b
File content as of revision 12:2f358065ba3f:
extern uLCD_4DGL uLCD; extern Mutex mutex; class Shooter { int x; public: Shooter(); void drawShooter(); void eraseShooter(); void moveLeft(); void moveRight(); int getLocation(); }; Shooter::Shooter() { x = 64; } void Shooter::drawShooter() { 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() { mutex.lock(); uLCD.filled_rectangle(0, 115, 127, 127, BACKGROUND); mutex.unlock(); } void Shooter::moveLeft() { 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() { if (x==104) return; mutex.lock(); Shooter::eraseShooter(); if (x==64) x = 104; if (x==24) x = 64; Shooter::drawShooter(); mutex.unlock(); } int Shooter::getLocation() { return x; }