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
- Committer:
- josh_ohara
- Date:
- 2020-04-06
- Revision:
- 15:dde4ce4bf7fe
- Parent:
- 14:e88bcf5c0887
- Child:
- 16:987f72d9bb8f
File content as of revision 15:dde4ce4bf7fe:
#include "BulletS.h"
BulletS::BulletS()
{
}
BulletS::~BulletS()
{
}
void BulletS::init() {
vector<Bullet> bullet_vector;
Shoot = 1;
}
void BulletS::render(N5110 &lcd) {
for (unsigned int i =0; i < bullet_vector.size(); i++) {
bullet_vector[i].render(lcd);
}
}
void BulletS::update(Gamepad &pad, N5110 &lcd, int shipx, int shipy) {
X = shipx;
Y = shipy;
ticker.attach(this,&BulletS::flag_set,0.5);
if((pad.A_pressed()==true)&&
(Shoot == 1)) {
Bullet new_bullet;
new_bullet.init(X,Y);
bullet_vector.push_back(new_bullet);
Shoot = 0;
}
for (int i = 0; i < bullet_vector.size(); i++) {
bullet_vector[i].update(pad,lcd);
}
}
vector<Bullet> BulletS::get_vector()
{
vector<Bullet> v = bullet_vector;
return v;
}
void BulletS::set_hit(int i, bool x)
{
bullet_vector[i].set_hit(x);
}
void BulletS::flag_set()
{
Shoot = 1;
Gamepad pad1;
pad1.leds_on();
wait(1);
pad1.leds_off();
}