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 MotionSensor
Diff: Entity/Player/Player.cpp
- Revision:
- 14:3361879490b2
- Parent:
- 13:d04a6caba40d
- Child:
- 15:44d5cc33d389
--- a/Entity/Player/Player.cpp Wed Apr 24 02:33:33 2019 +0000
+++ b/Entity/Player/Player.cpp Wed Apr 24 03:09:00 2019 +0000
@@ -18,10 +18,11 @@
frame.number = 0;
frame.max = 4;
for (int i = 0; i < bullets_max; i++){valid_bullets[i] = false;}
+ fire_rate_bullets = 0;
}
// Accessors
-int get_attack(){return 1;};
+int Player::get_attack(){return 1;};
// Functions
void Player::move(float mapped_x, float mapped_y){
@@ -65,6 +66,7 @@
}
void Player::buttons(bool button_A, bool button_B, bool button_Y, bool button_X){
+ fire_rate_bullets++;
if (button_Y){
face = 0;
}
@@ -77,11 +79,14 @@
else if (button_X){
face = 3;
}
- for (int i = 0; i < bullets_max; i++){
- if (!valid_bullets[i]){
- bullets_array[i] = new Bullets(position.x, position.y, face);
- valid_bullets[i] = true;
- break;
+ if (button_Y || button_B || button_A || button_X){
+ for (int i = 0; i < bullets_max; i++){
+ if (!valid_bullets[i] || fire_rate_bullets > 10){
+ bullets_array[i] = new Bullets(position.x, position.y, face);
+ valid_bullets[i] = true;
+ fire_rate_bullets = 0;
+ break;
+ }
}
}
}