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@4:b16b6078a432, 2020-05-18 (annotated)
- Committer:
- Albutt
- Date:
- Mon May 18 15:42:26 2020 +0000
- Revision:
- 4:b16b6078a432
- Child:
- 5:51fd6635141f
Bullets w/o despawn
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 | 4:b16b6078a432 | 34 | if(_dir == 0){ |
Albutt | 4:b16b6078a432 | 35 | lcd.drawLine(_x,_y, _x, 0,2); |
Albutt | 4:b16b6078a432 | 36 | } |
Albutt | 4:b16b6078a432 | 37 | else if (_dir == 1){ |
Albutt | 4:b16b6078a432 | 38 | lcd.drawLine(_x,_y, WIDTH, _y,2); |
Albutt | 4:b16b6078a432 | 39 | } |
Albutt | 4:b16b6078a432 | 40 | else if (_dir == 2){ |
Albutt | 4:b16b6078a432 | 41 | lcd.drawLine(_x,_y, _x, HEIGHT,2); |
Albutt | 4:b16b6078a432 | 42 | } |
Albutt | 4:b16b6078a432 | 43 | else if (_dir == 3){ |
Albutt | 4:b16b6078a432 | 44 | lcd.drawLine(_x,_y, 0, _y,2); |
Albutt | 4:b16b6078a432 | 45 | } |
Albutt | 4:b16b6078a432 | 46 | } |
Albutt | 4:b16b6078a432 | 47 | |
Albutt | 4:b16b6078a432 | 48 | void Bullets::update(int ex, int wy) |
Albutt | 4:b16b6078a432 | 49 | { |
Albutt | 4:b16b6078a432 | 50 | _x = ex; |
Albutt | 4:b16b6078a432 | 51 | _y = wy; |
Albutt | 4:b16b6078a432 | 52 | } |