SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Bullet.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; 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; } /*Bullet::Bullet(int x, int bottomY, uLCD_4DGL uLCD) { this->x = x; this->bottomY = bottomY; this->topY = bottomY + length; this->uLCD = uLCD; }*/ 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; }