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@8:0c6d6ed55851, 2020-05-22 (annotated)
- Committer:
- Albutt
- Date:
- Fri May 22 16:54:10 2020 +0000
- Revision:
- 8:0c6d6ed55851
- Parent:
- 7:0434857199cf
- Child:
- 9:62fe47a1374f
Collision with Enemy
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 | 7:0434857199cf | 3 | Bullets::Bullets(int ex, int wy, Direction d) |
Albutt | 4:b16b6078a432 | 4 | { |
Albutt | 7:0434857199cf | 5 | _x = ex; |
Albutt | 7:0434857199cf | 6 | _y = wy; |
Albutt | 7:0434857199cf | 7 | if (d == N) { |
Albutt | 7:0434857199cf | 8 | _dir = 0; |
Albutt | 7:0434857199cf | 9 | } |
Albutt | 7:0434857199cf | 10 | else if (d == E) { |
Albutt | 7:0434857199cf | 11 | _dir = 1; |
Albutt | 7:0434857199cf | 12 | } |
Albutt | 7:0434857199cf | 13 | else if (d == S) { |
Albutt | 7:0434857199cf | 14 | _dir = 2; |
Albutt | 7:0434857199cf | 15 | } |
Albutt | 7:0434857199cf | 16 | else if (d == W) { |
Albutt | 7:0434857199cf | 17 | _dir = 3; |
Albutt | 7:0434857199cf | 18 | } |
Albutt | 7:0434857199cf | 19 | //pcb.printf("Direction = %d", _dir); |
Albutt | 4:b16b6078a432 | 20 | } |
Albutt | 4:b16b6078a432 | 21 | |
Albutt | 4:b16b6078a432 | 22 | Bullets::~Bullets() |
Albutt | 4:b16b6078a432 | 23 | { |
Albutt | 4:b16b6078a432 | 24 | |
Albutt | 4:b16b6078a432 | 25 | } |
Albutt | 4:b16b6078a432 | 26 | |
Albutt | 4:b16b6078a432 | 27 | void Bullets::draw(N5110 &lcd) |
Albutt | 4:b16b6078a432 | 28 | { |
Albutt | 5:51fd6635141f | 29 | |
Albutt | 7:0434857199cf | 30 | lcd.drawRect(_x,_y,1,1,FILL_BLACK); |
Albutt | 7:0434857199cf | 31 | } |
Albutt | 7:0434857199cf | 32 | |
Albutt | 7:0434857199cf | 33 | void Bullets::update() |
Albutt | 7:0434857199cf | 34 | { |
Albutt | 4:b16b6078a432 | 35 | if(_dir == 0){ |
Albutt | 8:0c6d6ed55851 | 36 | _y = _y-3; |
Albutt | 4:b16b6078a432 | 37 | } |
Albutt | 4:b16b6078a432 | 38 | else if (_dir == 1){ |
Albutt | 8:0c6d6ed55851 | 39 | _x = _x+3; |
Albutt | 4:b16b6078a432 | 40 | } |
Albutt | 4:b16b6078a432 | 41 | else if (_dir == 2){ |
Albutt | 8:0c6d6ed55851 | 42 | _y = _y+3; |
Albutt | 4:b16b6078a432 | 43 | } |
Albutt | 4:b16b6078a432 | 44 | else if (_dir == 3){ |
Albutt | 8:0c6d6ed55851 | 45 | _x = _x-3; |
Albutt | 4:b16b6078a432 | 46 | } |
Albutt | 4:b16b6078a432 | 47 | } |
Albutt | 7:0434857199cf | 48 | int Bullets::get_x(){ |
Albutt | 7:0434857199cf | 49 | return _x; |
Albutt | 7:0434857199cf | 50 | } |
Albutt | 7:0434857199cf | 51 | |
Albutt | 7:0434857199cf | 52 | int Bullets::get_y(){ |
Albutt | 7:0434857199cf | 53 | return _y; |
Albutt | 7:0434857199cf | 54 | } |
Albutt | 7:0434857199cf | 55 |