SharpShooter

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Committer:
jboettcher
Date:
Fri Oct 28 20:07:38 2016 +0000
Revision:
11:55b65415b6ba
Parent:
7:ed2c73e25681
Child:
12:2f358065ba3f
First compile;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jboettcher 11:55b65415b6ba 1 extern uLCD_4DGL uLCD;
jboettcher 11:55b65415b6ba 2
jboettcher 11:55b65415b6ba 3 struct BulletLocation {
jboettcher 11:55b65415b6ba 4 int x, topY, bottomY;
jboettcher 11:55b65415b6ba 5 };
jboettcher 11:55b65415b6ba 6
SeanBuckingham 2:e8f2b2320353 7 class Bullet {
SeanBuckingham 2:e8f2b2320353 8
SeanBuckingham 7:ed2c73e25681 9 int x, topY, bottomY;
jboettcher 11:55b65415b6ba 10 int length;
jboettcher 11:55b65415b6ba 11 int speed;
jboettcher 11:55b65415b6ba 12
SeanBuckingham 7:ed2c73e25681 13
SeanBuckingham 7:ed2c73e25681 14 public:
jboettcher 11:55b65415b6ba 15 Bullet();
SeanBuckingham 7:ed2c73e25681 16 void drawBullet(int x, int bottomY);
SeanBuckingham 7:ed2c73e25681 17 void eraseBullet();
jboettcher 11:55b65415b6ba 18 void move();
jboettcher 11:55b65415b6ba 19 BulletLocation getLocation();
SeanBuckingham 7:ed2c73e25681 20 };
SeanBuckingham 7:ed2c73e25681 21
jboettcher 11:55b65415b6ba 22 Bullet::Bullet() {
jboettcher 11:55b65415b6ba 23 length = 3;
jboettcher 11:55b65415b6ba 24 speed = 3;
jboettcher 11:55b65415b6ba 25 x=1;
jboettcher 11:55b65415b6ba 26 topY=2;
jboettcher 11:55b65415b6ba 27 bottomY=3;
SeanBuckingham 7:ed2c73e25681 28 }
SeanBuckingham 7:ed2c73e25681 29
SeanBuckingham 7:ed2c73e25681 30 /*Bullet::Bullet(int x, int bottomY, uLCD_4DGL uLCD) {
SeanBuckingham 7:ed2c73e25681 31 this->x = x;
SeanBuckingham 7:ed2c73e25681 32 this->bottomY = bottomY;
SeanBuckingham 7:ed2c73e25681 33 this->topY = bottomY + length;
SeanBuckingham 7:ed2c73e25681 34 this->uLCD = uLCD;
SeanBuckingham 7:ed2c73e25681 35 }*/
SeanBuckingham 7:ed2c73e25681 36
SeanBuckingham 7:ed2c73e25681 37 void Bullet::drawBullet(int x, int bottomY) {
SeanBuckingham 7:ed2c73e25681 38 this->x = x;
SeanBuckingham 7:ed2c73e25681 39 this->bottomY = bottomY;
SeanBuckingham 7:ed2c73e25681 40 this->topY = bottomY + length;
SeanBuckingham 7:ed2c73e25681 41 uLCD.line(x,topY,x,bottomY, 0xFFFFFF);
SeanBuckingham 7:ed2c73e25681 42 }
SeanBuckingham 7:ed2c73e25681 43
SeanBuckingham 7:ed2c73e25681 44 void Bullet::move() {
SeanBuckingham 7:ed2c73e25681 45 bottomY+= speed;
SeanBuckingham 7:ed2c73e25681 46 drawBullet(x, bottomY);
SeanBuckingham 7:ed2c73e25681 47 }
SeanBuckingham 7:ed2c73e25681 48
SeanBuckingham 7:ed2c73e25681 49 void Bullet::eraseBullet() {
SeanBuckingham 7:ed2c73e25681 50 uLCD.line(x,topY,x,bottomY, 0x000000);
SeanBuckingham 7:ed2c73e25681 51 }
SeanBuckingham 7:ed2c73e25681 52
jboettcher 11:55b65415b6ba 53 BulletLocation Bullet::getLocation() {
jboettcher 11:55b65415b6ba 54 BulletLocation coor {x, topY, bottomY};
SeanBuckingham 7:ed2c73e25681 55 return coor;
SeanBuckingham 7:ed2c73e25681 56 }