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
Revision 15:44d5cc33d389, committed 2019-04-24
- Comitter:
- el17sm
- Date:
- Wed Apr 24 06:28:14 2019 +0000
- Parent:
- 14:3361879490b2
- Child:
- 16:ddb203a74dfc
- Child:
- 20:6405835af6e2
- Commit message:
- Fully functioning without map generation and map movement. Only Headless enemy
Changed in this revision
--- a/Entity/Bullets/Bullets.cpp Wed Apr 24 03:09:00 2019 +0000
+++ b/Entity/Bullets/Bullets.cpp Wed Apr 24 06:28:14 2019 +0000
@@ -11,7 +11,7 @@
sprite_size.width = 2;
sprite_size.height = 2;
sprite_size.offset_x = 0;
- sprite_size.offset_y = 0;
+ sprite_size.offset_y = 1;
direction = dir;
}
@@ -38,7 +38,7 @@
if (matrix_collision_test(position.x, position.y, 0)){
return true;
}
- else if ((!(0 < position.x < 84)) || (!(0 < position.y < 48))){
+ if ((0 > position.x) || (position.x > 84) || (0 > position.y) || (position.y > 48)){
return true;
}
return false;
--- a/Entity/Player/Player.cpp Wed Apr 24 03:09:00 2019 +0000
+++ b/Entity/Player/Player.cpp Wed Apr 24 06:28:14 2019 +0000
@@ -18,7 +18,8 @@
frame.number = 0;
frame.max = 4;
for (int i = 0; i < bullets_max; i++){valid_bullets[i] = false;}
- fire_rate_bullets = 0;
+ fire_rate_counter = 0;
+ fire_rate_delay = 5;
}
// Accessors
@@ -66,7 +67,7 @@
}
void Player::buttons(bool button_A, bool button_B, bool button_Y, bool button_X){
- fire_rate_bullets++;
+ fire_rate_counter++;
if (button_Y){
face = 0;
}
@@ -81,10 +82,10 @@
}
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);
+ if (!valid_bullets[i] && fire_rate_counter > fire_rate_delay){
+ bullets_array[i] = new Bullets(position.x+2, position.y-2, face);
valid_bullets[i] = true;
- fire_rate_bullets = 0;
+ fire_rate_counter = 0;
break;
}
}
--- a/Entity/Player/Player.h Wed Apr 24 03:09:00 2019 +0000
+++ b/Entity/Player/Player.h Wed Apr 24 06:28:14 2019 +0000
@@ -21,7 +21,8 @@
// variables
Bullets *bullets_array[bullets_max];
bool valid_bullets[bullets_max];
- int fire_rate_bullets;
+ int fire_rate_counter;
+ int fire_rate_delay;
};
const float player_speed = 1.2;