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@11:c174d84e4866, 2020-04-01 (annotated)
- Committer:
- josh_ohara
- Date:
- Wed Apr 01 11:23:25 2020 +0000
- Revision:
- 11:c174d84e4866
- Parent:
- 8:86cb9a9f8a73
- Child:
- 12:be491ab6e742
Bullet vector completed
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| josh_ohara | 2:c2316b659b97 | 1 | |
| josh_ohara | 11:c174d84e4866 | 2 | #include "BulletS.h" |
| josh_ohara | 2:c2316b659b97 | 3 | |
| josh_ohara | 11:c174d84e4866 | 4 | BulletS::BulletS() |
| josh_ohara | 11:c174d84e4866 | 5 | { |
| josh_ohara | 11:c174d84e4866 | 6 | } |
| josh_ohara | 11:c174d84e4866 | 7 | BulletS::~BulletS() |
| josh_ohara | 11:c174d84e4866 | 8 | { |
| josh_ohara | 11:c174d84e4866 | 9 | } |
| josh_ohara | 11:c174d84e4866 | 10 | |
| josh_ohara | 11:c174d84e4866 | 11 | void BulletS::init() { |
| josh_ohara | 11:c174d84e4866 | 12 | vector<Bullet> bullet_vector; |
| josh_ohara | 11:c174d84e4866 | 13 | int Shot = 0; |
| josh_ohara | 11:c174d84e4866 | 14 | } |
| josh_ohara | 2:c2316b659b97 | 15 | |
| josh_ohara | 11:c174d84e4866 | 16 | void BulletS::render(N5110 &lcd) { |
| josh_ohara | 11:c174d84e4866 | 17 | for (unsigned int i =0; i < bullet_vector.size(); i++) { |
| josh_ohara | 11:c174d84e4866 | 18 | bullet_vector[i].render(lcd); |
| josh_ohara | 11:c174d84e4866 | 19 | } |
| josh_ohara | 11:c174d84e4866 | 20 | } |
| josh_ohara | 2:c2316b659b97 | 21 | |
| josh_ohara | 11:c174d84e4866 | 22 | void BulletS::update(Gamepad &pad, int shipx, int shipy) { |
| josh_ohara | 11:c174d84e4866 | 23 | X = shipx; |
| josh_ohara | 11:c174d84e4866 | 24 | Y = shipy; |
| josh_ohara | 11:c174d84e4866 | 25 | if(pad.A_pressed()==true) { |
| josh_ohara | 11:c174d84e4866 | 26 | Shot++; |
| josh_ohara | 11:c174d84e4866 | 27 | Bullet new_bullet; |
| josh_ohara | 11:c174d84e4866 | 28 | new_bullet.init(X,Y); |
| josh_ohara | 11:c174d84e4866 | 29 | bullet_vector.push_back(new_bullet); |
| josh_ohara | 11:c174d84e4866 | 30 | } |
| josh_ohara | 11:c174d84e4866 | 31 | for (unsigned int i =0; i < bullet_vector.size(); i++) { |
| josh_ohara | 11:c174d84e4866 | 32 | bullet_vector[i].update(pad); |
| josh_ohara | 11:c174d84e4866 | 33 | } |
| josh_ohara | 11:c174d84e4866 | 34 | } |