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@3:8a140aa1ddcd, 2020-03-14 (annotated)
- Committer:
- josh_ohara
- Date:
- Sat Mar 14 21:19:58 2020 +0000
- Revision:
- 3:8a140aa1ddcd
- Parent:
- 2:c2316b659b97
- Child:
- 4:18a1fc4c38e0
Some debugging done. Questions for class written.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| josh_ohara | 3:8a140aa1ddcd | 1 | #include "BulletS.h" |
| josh_ohara | 3:8a140aa1ddcd | 2 | #include "Ship.cpp" |
| josh_ohara | 2:c2316b659b97 | 3 | |
| josh_ohara | 2:c2316b659b97 | 4 | Bullet::Bullet() |
| josh_ohara | 2:c2316b659b97 | 5 | { |
| josh_ohara | 2:c2316b659b97 | 6 | } |
| josh_ohara | 2:c2316b659b97 | 7 | |
| josh_ohara | 3:8a140aa1ddcd | 8 | void Bullet::init(int size, int speed) |
| josh_ohara | 3:8a140aa1ddcd | 9 | { int ShipHeight = get_height(); |
| josh_ohara | 2:c2316b659b97 | 10 | Size = size; |
| josh_ohara | 3:8a140aa1ddcd | 11 | Speed = speed; |
| josh_ohara | 2:c2316b659b97 | 12 | X = WIDTH/2 - Size/2; //Middle of the ship |
| josh_ohara | 3:8a140aa1ddcd | 13 | Y = HEIGHT - ShipHeight; //Top of the ship |
| josh_ohara | 2:c2316b659b97 | 14 | } |
| josh_ohara | 2:c2316b659b97 | 15 | |
| josh_ohara | 2:c2316b659b97 | 16 | void Bullet::draw(N5110 &lcd) |
| josh_ohara | 2:c2316b659b97 | 17 | { |
| josh_ohara | 2:c2316b659b97 | 18 | lcd.drawRect(X,Y,Size,Size,FILL_BLACK); |
| josh_ohara | 2:c2316b659b97 | 19 | } |
| josh_ohara | 2:c2316b659b97 | 20 | |
| josh_ohara | 2:c2316b659b97 | 21 | void update(); |
| josh_ohara | 2:c2316b659b97 | 22 | if(pad.A_pressed()) { |
| josh_ohara | 2:c2316b659b97 | 23 | Speed = 1; //shoots bullet if pad a pressed |
| josh_ohara | 2:c2316b659b97 | 24 | Y -= Speed; |
| josh_ohara | 2:c2316b659b97 | 25 | } |
| josh_ohara | 2:c2316b659b97 | 26 | |
| josh_ohara | 2:c2316b659b97 | 27 | Vector2D Ship::get_position(); |
| josh_ohara | 2:c2316b659b97 | 28 | Vector2D p = {X,Y}; |
| josh_ohara | 2:c2316b659b97 | 29 | return p; |
| josh_ohara | 2:c2316b659b97 | 30 | } |
| josh_ohara | 2:c2316b659b97 | 31 | |
| josh_ohara | 2:c2316b659b97 | 32 | |
| josh_ohara | 2:c2316b659b97 | 33 | |
| josh_ohara | 2:c2316b659b97 | 34 |