A rouge-like rpg, heavily inspired on the binding of isaac. Running on a FRDM-K64F Mbed board. C++.

Dependencies:   mbed MotionSensor

Revision:
38:09832e662803
Parent:
37:a404860171a9
--- a/RoomEngine/RoomEngine.cpp	Tue May 07 03:47:39 2019 +0000
+++ b/RoomEngine/RoomEngine.cpp	Tue May 07 09:09:38 2019 +0000
@@ -235,6 +235,12 @@
 
 void RoomEngine::check_damage_player()
 {
+    check_damage_players_by_collision();
+    check_damage_players_by_bullets();
+}
+
+void RoomEngine::check_damage_players_by_collision()
+{
     for (int i = 0; i < MAX_ENEMIES; i++) {
         if (room->valid_enemies[i]) {
             if(entity_collision(*player, *room->enemies[i])) {
@@ -253,6 +259,21 @@
     }
 }
 
+void RoomEngine::check_damage_players_by_bullets()
+{
+    for(int j = 0; j < MAX_ENEMIES; j++) {
+        if (room->enemies[j]->get_type() == 4) {
+            for (int i = 0; i < MAX_BULLETS; i++) {
+                if (room->enemies[j]->valid_bullets[i]) && (!room->enemies[j]->update_bullets(room->get_current_map_2d(), room->get_doorways())) && (entity_collision(*player, *enemies[j]->bullets_array[i])) {
+                    player->take_damage(room->enemies[j]->get_attack());
+                    room->enemies[j]->valid_bullets[i] = false;
+                    delete room->enemies[j]->bullets_array[i];
+                }
+            }
+        }
+    }
+}
+
 void RoomEngine::check_damage_enemies()
 {
     check_damage_enemies_by_bullets();
@@ -262,8 +283,7 @@
 {
     for (int i = 0; i < bullets_max; i++) {
         if (player->valid_bullets[i]) {
-            if (player->update_bullets(room->get_current_map_2d(), room->get_doorways())) {
-            } else {
+            if (!player->update_bullets(room->get_current_map_2d(), room->get_doorways())) {
                 for (int j = 0; j < MAX_ENEMIES; j++) {
                     if (room->valid_enemies[j] && (entity_collision(*player->bullets_array[i], *room->enemies[j]))) {
                         room->enemies[j]->take_damage(player->get_attack());