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: mbed
Bullets/Bullets.cpp@5:51fd6635141f, 2020-05-20 (annotated)
- Committer:
- Albutt
- Date:
- Wed May 20 21:39:09 2020 +0000
- Revision:
- 5:51fd6635141f
- Parent:
- 4:b16b6078a432
- Child:
- 7:0434857199cf
Enemy Class Finished;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Albutt | 4:b16b6078a432 | 1 | #include "Bullets.h" |
Albutt | 4:b16b6078a432 | 2 | Serial pcb(USBTX, USBRX); |
Albutt | 4:b16b6078a432 | 3 | Bullets::Bullets() |
Albutt | 4:b16b6078a432 | 4 | { |
Albutt | 4:b16b6078a432 | 5 | |
Albutt | 4:b16b6078a432 | 6 | } |
Albutt | 4:b16b6078a432 | 7 | |
Albutt | 4:b16b6078a432 | 8 | Bullets::~Bullets() |
Albutt | 4:b16b6078a432 | 9 | { |
Albutt | 4:b16b6078a432 | 10 | |
Albutt | 4:b16b6078a432 | 11 | } |
Albutt | 4:b16b6078a432 | 12 | |
Albutt | 4:b16b6078a432 | 13 | void Bullets::init(int ex, int wy, int d) |
Albutt | 4:b16b6078a432 | 14 | { |
Albutt | 4:b16b6078a432 | 15 | _size = 1; |
Albutt | 4:b16b6078a432 | 16 | _speed = 4; |
Albutt | 4:b16b6078a432 | 17 | _x = ex; |
Albutt | 4:b16b6078a432 | 18 | _y = wy; |
Albutt | 4:b16b6078a432 | 19 | |
Albutt | 4:b16b6078a432 | 20 | if (d == 0) { |
Albutt | 4:b16b6078a432 | 21 | _dir = 0; |
Albutt | 4:b16b6078a432 | 22 | } else if (d == 1) { |
Albutt | 4:b16b6078a432 | 23 | _dir = 1; |
Albutt | 4:b16b6078a432 | 24 | } else if (d == 2) { |
Albutt | 4:b16b6078a432 | 25 | _dir = 2; |
Albutt | 4:b16b6078a432 | 26 | } else { |
Albutt | 4:b16b6078a432 | 27 | _dir = 3; |
Albutt | 4:b16b6078a432 | 28 | } |
Albutt | 4:b16b6078a432 | 29 | //pcb.printf("Direction = %d", _dir); |
Albutt | 4:b16b6078a432 | 30 | } |
Albutt | 4:b16b6078a432 | 31 | |
Albutt | 4:b16b6078a432 | 32 | void Bullets::draw(N5110 &lcd) |
Albutt | 4:b16b6078a432 | 33 | { |
Albutt | 5:51fd6635141f | 34 | |
Albutt | 4:b16b6078a432 | 35 | if(_dir == 0){ |
Albutt | 5:51fd6635141f | 36 | lcd.drawLine(_x,_y, _x, 0,1); |
Albutt | 4:b16b6078a432 | 37 | } |
Albutt | 4:b16b6078a432 | 38 | else if (_dir == 1){ |
Albutt | 5:51fd6635141f | 39 | lcd.drawLine(_x,_y, WIDTH, _y,1); |
Albutt | 4:b16b6078a432 | 40 | } |
Albutt | 4:b16b6078a432 | 41 | else if (_dir == 2){ |
Albutt | 5:51fd6635141f | 42 | lcd.drawLine(_x,_y, _x, HEIGHT,1); |
Albutt | 4:b16b6078a432 | 43 | } |
Albutt | 4:b16b6078a432 | 44 | else if (_dir == 3){ |
Albutt | 5:51fd6635141f | 45 | lcd.drawLine(_x,_y, 0, _y,1); |
Albutt | 4:b16b6078a432 | 46 | } |
Albutt | 4:b16b6078a432 | 47 | } |
Albutt | 4:b16b6078a432 | 48 | |
Albutt | 4:b16b6078a432 | 49 | void Bullets::update(int ex, int wy) |
Albutt | 4:b16b6078a432 | 50 | { |
Albutt | 4:b16b6078a432 | 51 | _x = ex; |
Albutt | 4:b16b6078a432 | 52 | _y = wy; |
Albutt | 4:b16b6078a432 | 53 | } |