Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Bullet.h
00001 extern uLCD_4DGL uLCD; 00002 extern Mutex mutex; 00003 00004 struct BulletLocation { 00005 int x, topY, bottomY; 00006 }; 00007 00008 class Bullet { 00009 00010 int x, topY, bottomY; 00011 int length; 00012 int speed; 00013 00014 00015 public: 00016 Bullet(); 00017 void drawBullet(int x, int bottomY); 00018 void eraseBullet(); 00019 void move(); 00020 BulletLocation getLocation(); 00021 }; 00022 00023 Bullet::Bullet() { 00024 length = 3; 00025 speed = 3; 00026 x=1; 00027 topY=2; 00028 bottomY=3; 00029 } 00030 00031 void Bullet::drawBullet(int x2, int bottomY2) { 00032 x = x2; 00033 bottomY = bottomY2; 00034 topY = bottomY + length; 00035 mutex.lock(); 00036 uLCD.line(x,topY,x,bottomY, BLACK); 00037 mutex.unlock(); 00038 00039 } 00040 00041 void Bullet::move() { 00042 Bullet::eraseBullet(); 00043 bottomY -= speed; 00044 Bullet::drawBullet(x, bottomY); 00045 } 00046 00047 void Bullet::eraseBullet() { 00048 mutex.lock(); 00049 uLCD.line(x,topY,x,bottomY, BACKGROUND); 00050 mutex.unlock(); 00051 00052 } 00053 00054 BulletLocation Bullet::getLocation() { 00055 BulletLocation coor {x, topY, bottomY}; 00056 return coor; 00057 }
Generated on Mon Jul 18 2022 01:34:28 by
1.7.2