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:18a1fc4c38e0, 2020-03-22 (annotated)
- Committer:
- josh_ohara
- Date:
- Sun Mar 22 18:51:00 2020 +0000
- Revision:
- 4:18a1fc4c38e0
- Parent:
- 3:8a140aa1ddcd
- Child:
- 5:e5bb95fb308b
Adding variables to control lives of aliens and ship and rock components
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 | 4:18a1fc4c38e0 | 8 | void Bullet::init(int size, int speed) { |
| josh_ohara | 2:c2316b659b97 | 9 | Size = size; |
| josh_ohara | 3:8a140aa1ddcd | 10 | Speed = speed; |
| josh_ohara | 2:c2316b659b97 | 11 | X = WIDTH/2 - Size/2; //Middle of the ship |
| josh_ohara | 4:18a1fc4c38e0 | 12 | Y = HEIGHT - Height; //Top of the ship |
| josh_ohara | 2:c2316b659b97 | 13 | } |
| josh_ohara | 2:c2316b659b97 | 14 | |
| josh_ohara | 2:c2316b659b97 | 15 | void Bullet::draw(N5110 &lcd) |
| josh_ohara | 2:c2316b659b97 | 16 | { |
| josh_ohara | 2:c2316b659b97 | 17 | lcd.drawRect(X,Y,Size,Size,FILL_BLACK); |
| josh_ohara | 2:c2316b659b97 | 18 | } |
| josh_ohara | 2:c2316b659b97 | 19 | |
| josh_ohara | 4:18a1fc4c38e0 | 20 | void Bullet::update() { |
| josh_ohara | 2:c2316b659b97 | 21 | if(pad.A_pressed()) { |
| josh_ohara | 2:c2316b659b97 | 22 | Speed = 1; //shoots bullet if pad a pressed |
| josh_ohara | 2:c2316b659b97 | 23 | Y -= Speed; |
| josh_ohara | 2:c2316b659b97 | 24 | } |
| josh_ohara | 4:18a1fc4c38e0 | 25 | } |
| josh_ohara | 2:c2316b659b97 | 26 | |
| josh_ohara | 4:18a1fc4c38e0 | 27 | Vector2D Bullet::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 | 4:18a1fc4c38e0 | 32 | //void Bullet::set_hit(bool hit) { |
| josh_ohara | 4:18a1fc4c38e0 | 33 | // bool Hit == hit; |
| josh_ohara | 4:18a1fc4c38e0 | 34 | //} |
| josh_ohara | 4:18a1fc4c38e0 | 35 | |
| josh_ohara | 2:c2316b659b97 | 36 | |
| josh_ohara | 2:c2316b659b97 | 37 | |
| josh_ohara | 2:c2316b659b97 | 38 |