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
Diff: BulletS/BulletS.cpp
- Revision:
- 15:dde4ce4bf7fe
- Parent:
- 14:e88bcf5c0887
- Child:
- 16:987f72d9bb8f
--- a/BulletS/BulletS.cpp Fri Apr 03 11:19:53 2020 +0000
+++ b/BulletS/BulletS.cpp Mon Apr 06 15:37:02 2020 +0000
@@ -10,7 +10,7 @@
void BulletS::init() {
vector<Bullet> bullet_vector;
- int Shot = 0;
+ Shoot = 1;
}
void BulletS::render(N5110 &lcd) {
@@ -22,11 +22,13 @@
void BulletS::update(Gamepad &pad, N5110 &lcd, int shipx, int shipy) {
X = shipx;
Y = shipy;
- if(pad.A_pressed()==true) {
- Shot++;
+ 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);
@@ -43,3 +45,13 @@
{
bullet_vector[i].set_hit(x);
}
+
+void BulletS::flag_set()
+{
+ Shoot = 1;
+ Gamepad pad1;
+ pad1.leds_on();
+ wait(1);
+ pad1.leds_off();
+}
+