SharpShooter
Dependencies: 4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player
Bullet.h@7:ed2c73e25681, 2016-10-28 (annotated)
- Committer:
- SeanBuckingham
- Date:
- Fri Oct 28 00:36:52 2016 +0000
- Revision:
- 7:ed2c73e25681
- Parent:
- 2:e8f2b2320353
- Child:
- 11:55b65415b6ba
bullet class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SeanBuckingham | 2:e8f2b2320353 | 1 | class Bullet { |
SeanBuckingham | 2:e8f2b2320353 | 2 | |
SeanBuckingham | 7:ed2c73e25681 | 3 | int x, topY, bottomY; |
SeanBuckingham | 7:ed2c73e25681 | 4 | int length = 3; |
SeanBuckingham | 7:ed2c73e25681 | 5 | int speed = 3; |
SeanBuckingham | 7:ed2c73e25681 | 6 | uLCD_4DGL uLCD; |
SeanBuckingham | 7:ed2c73e25681 | 7 | struct Coordinate { |
SeanBuckingham | 7:ed2c73e25681 | 8 | int x1, y1, x2, y2; |
SeanBuckingham | 7:ed2c73e25681 | 9 | } |
SeanBuckingham | 7:ed2c73e25681 | 10 | |
SeanBuckingham | 7:ed2c73e25681 | 11 | public: |
SeanBuckingham | 7:ed2c73e25681 | 12 | Bullet(uLCD_4DGL uLCD); |
SeanBuckingham | 7:ed2c73e25681 | 13 | void drawBullet(int x, int bottomY); |
SeanBuckingham | 7:ed2c73e25681 | 14 | void eraseBullet(); |
SeanBuckingham | 7:ed2c73e25681 | 15 | void move(); |
SeanBuckingham | 7:ed2c73e25681 | 16 | }; |
SeanBuckingham | 7:ed2c73e25681 | 17 | |
SeanBuckingham | 7:ed2c73e25681 | 18 | Bullet::Bullet(uLCD_4DGL uLCD) { |
SeanBuckingham | 7:ed2c73e25681 | 19 | this->uLCD = uLCD; |
SeanBuckingham | 7:ed2c73e25681 | 20 | } |
SeanBuckingham | 7:ed2c73e25681 | 21 | |
SeanBuckingham | 7:ed2c73e25681 | 22 | /*Bullet::Bullet(int x, int bottomY, uLCD_4DGL uLCD) { |
SeanBuckingham | 7:ed2c73e25681 | 23 | this->x = x; |
SeanBuckingham | 7:ed2c73e25681 | 24 | this->bottomY = bottomY; |
SeanBuckingham | 7:ed2c73e25681 | 25 | this->topY = bottomY + length; |
SeanBuckingham | 7:ed2c73e25681 | 26 | this->uLCD = uLCD; |
SeanBuckingham | 7:ed2c73e25681 | 27 | }*/ |
SeanBuckingham | 7:ed2c73e25681 | 28 | |
SeanBuckingham | 7:ed2c73e25681 | 29 | void Bullet::drawBullet(int x, int bottomY) { |
SeanBuckingham | 7:ed2c73e25681 | 30 | this->x = x; |
SeanBuckingham | 7:ed2c73e25681 | 31 | this->bottomY = bottomY; |
SeanBuckingham | 7:ed2c73e25681 | 32 | this->topY = bottomY + length; |
SeanBuckingham | 7:ed2c73e25681 | 33 | uLCD.line(x,topY,x,bottomY, 0xFFFFFF); |
SeanBuckingham | 7:ed2c73e25681 | 34 | } |
SeanBuckingham | 7:ed2c73e25681 | 35 | |
SeanBuckingham | 7:ed2c73e25681 | 36 | void Bullet::move() { |
SeanBuckingham | 7:ed2c73e25681 | 37 | bottomY+= speed; |
SeanBuckingham | 7:ed2c73e25681 | 38 | drawBullet(x, bottomY); |
SeanBuckingham | 7:ed2c73e25681 | 39 | } |
SeanBuckingham | 7:ed2c73e25681 | 40 | |
SeanBuckingham | 7:ed2c73e25681 | 41 | void Bullet::eraseBullet() { |
SeanBuckingham | 7:ed2c73e25681 | 42 | uLCD.line(x,topY,x,bottomY, 0x000000); |
SeanBuckingham | 7:ed2c73e25681 | 43 | } |
SeanBuckingham | 7:ed2c73e25681 | 44 | |
SeanBuckingham | 7:ed2c73e25681 | 45 | Coordinate Bullet::getLocation() { |
SeanBuckingham | 7:ed2c73e25681 | 46 | Coordinate coor = {x, topY, x, bottomY;} |
SeanBuckingham | 7:ed2c73e25681 | 47 | return coor; |
SeanBuckingham | 7:ed2c73e25681 | 48 | } |