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@6:5bea67cc96f9, 2020-03-23 (annotated)
- Committer:
- josh_ohara
- Date:
- Mon Mar 23 15:20:59 2020 +0000
- Revision:
- 6:5bea67cc96f9
- Parent:
- 5:e5bb95fb308b
- Child:
- 7:06a2558155f0
Beginning engine contruction
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| josh_ohara | 3:8a140aa1ddcd | 1 | #include "BulletS.h" |
| josh_ohara | 2:c2316b659b97 | 2 | |
| josh_ohara | 2:c2316b659b97 | 3 | Bullet::Bullet() |
| josh_ohara | 2:c2316b659b97 | 4 | { |
| josh_ohara | 2:c2316b659b97 | 5 | } |
| josh_ohara | 2:c2316b659b97 | 6 | |
| josh_ohara | 6:5bea67cc96f9 | 7 | void Bullet::init(int size, int x, int y) { |
| josh_ohara | 2:c2316b659b97 | 8 | Size = size; |
| josh_ohara | 6:5bea67cc96f9 | 9 | Speed = 0; |
| josh_ohara | 6:5bea67cc96f9 | 10 | X = x; //x=Middle of the ship |
| josh_ohara | 6:5bea67cc96f9 | 11 | Y = HEIGHT; //y=Top of the ship Height is ship Height |
| josh_ohara | 2:c2316b659b97 | 12 | } |
| josh_ohara | 2:c2316b659b97 | 13 | |
| josh_ohara | 2:c2316b659b97 | 14 | void Bullet::draw(N5110 &lcd) |
| josh_ohara | 2:c2316b659b97 | 15 | { |
| josh_ohara | 2:c2316b659b97 | 16 | lcd.drawRect(X,Y,Size,Size,FILL_BLACK); |
| josh_ohara | 2:c2316b659b97 | 17 | } |
| josh_ohara | 2:c2316b659b97 | 18 | |
| josh_ohara | 4:18a1fc4c38e0 | 19 | void Bullet::update() { |
| josh_ohara | 2:c2316b659b97 | 20 | if(pad.A_pressed()) { |
| josh_ohara | 6:5bea67cc96f9 | 21 | Speed = 1; //shoots bullet if pad a pressed |
| josh_ohara | 2:c2316b659b97 | 22 | Y -= Speed; |
| josh_ohara | 2:c2316b659b97 | 23 | } |
| josh_ohara | 4:18a1fc4c38e0 | 24 | } |
| josh_ohara | 2:c2316b659b97 | 25 | |
| josh_ohara | 4:18a1fc4c38e0 | 26 | Vector2D Bullet::get_position() { |
| josh_ohara | 2:c2316b659b97 | 27 | Vector2D p = {X,Y}; |
| josh_ohara | 2:c2316b659b97 | 28 | return p; |
| josh_ohara | 2:c2316b659b97 | 29 | } |
| josh_ohara | 2:c2316b659b97 | 30 | |
| josh_ohara | 4:18a1fc4c38e0 | 31 | //void Bullet::set_hit(bool hit) { |
| josh_ohara | 4:18a1fc4c38e0 | 32 | // bool Hit == hit; |
| josh_ohara | 4:18a1fc4c38e0 | 33 | //} |
| josh_ohara | 4:18a1fc4c38e0 | 34 | |
| josh_ohara | 2:c2316b659b97 | 35 | |
| josh_ohara | 2:c2316b659b97 | 36 | |
| josh_ohara | 2:c2316b659b97 | 37 |