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 20:6405835af6e2, committed 2019-04-25
- Comitter:
- el17sm
- Date:
- Thu Apr 25 04:40:30 2019 +0000
- Parent:
- 15:44d5cc33d389
- Commit message:
- the true updated headless only functional game
Changed in this revision
--- a/Entity/Entity.cpp Wed Apr 24 06:28:14 2019 +0000
+++ b/Entity/Entity.cpp Thu Apr 25 04:40:30 2019 +0000
@@ -11,7 +11,7 @@
position.y = prev_pos.y;
}
}
-void Entity::update_prev_pos(){prev_pos = position;};
+void Entity::update_prev_pos(){prev_pos = position;}
bool Entity::matrix_collision_test(float pos_x, float pos_y, int map_no){
for (int j = pos_y; j < (int)pos_y + hitbox.height; j++){
--- a/Entity/Headless/Headless.cpp Wed Apr 24 06:28:14 2019 +0000
+++ b/Entity/Headless/Headless.cpp Thu Apr 25 04:40:30 2019 +0000
@@ -43,6 +43,10 @@
face = 3;
}
+ // wall collision
+ undo_move_x(matrix_collision_test(position.x, prev_pos.y, 0));
+ undo_move_y(matrix_collision_test(prev_pos.x, position.y, 0));
+
if (frame.number < frame.max){
frame.count++;
}
--- a/main.cpp Wed Apr 24 06:28:14 2019 +0000
+++ b/main.cpp Thu Apr 25 04:40:30 2019 +0000
@@ -103,24 +103,27 @@
goto gameover;
}
}
- };
+ }
for (int i = 0; i < bullets_max; i++){
if (player.valid_bullets[i]){
- for (int j = 0; j < no_of_enemies; j++){
- if (valid_enemies[j]){
- if(entity_collision(*player.bullets_array[i], *enemies[j])){
- enemies[j]->take_damage(player.get_attack());
- player.valid_bullets[i] = false;
- player.bullets_array[i]->~Bullets;
+ if (player.bullets_array[i]->out_of_bounds_check()){
+ player.valid_bullets[i] = false;
+ player.bullets_array[i]->~Bullets;
+ }
+ else {
+ for (int j = 0; j < no_of_enemies; j++){
+ if (valid_enemies[j]){
+ if(entity_collision(*player.bullets_array[i], *enemies[j])){
+ enemies[j]->take_damage(player.get_attack());
+ player.valid_bullets[i] = false;
+ player.bullets_array[i]->~Bullets;
+ break;
+ }
}
}
- if (player.bullets_array[i]->out_of_bounds_check()){
- player.valid_bullets[i] = false;
- player.bullets_array[i]->~Bullets;
- }
- };
+ }
}
- };
+ }
// Player Movement
Vector2D mapped_coord = gamepad.get_mapped_coord();