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

Dependencies:   mbed MotionSensor

Revision:
29:6b8411bb040a
Parent:
28:98848e6a77a2
Child:
30:ec915d24d3e9
diff -r 98848e6a77a2 -r 6b8411bb040a RoomEngine/RoomEngine.cpp
--- a/RoomEngine/RoomEngine.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/RoomEngine/RoomEngine.cpp	Sat May 04 15:39:20 2019 +0000
@@ -1,7 +1,8 @@
 #include "RoomEngine.h"
 RoomEngine::RoomEngine()
 {
-    
+    _room_x = 5;
+    _room_y = 5;
 }
 
 RoomEngine::~RoomEngine()
@@ -9,19 +10,14 @@
     delete player;
 }
 
-void RoomEngine::init(Player &current_player, Room &current_room)
+void RoomEngine::load(Player &current_player, Room *current_room)
 {
     player = &current_player;
-    room = &current_room;
+    room = current_room;
     set_input(0,0,0,0,0,0,0,0);
     update_player_position(check_player_room_position());
 }
 
-void RoomEngine::save_room(Room &current_room)
-{
-    
-}
-
 void RoomEngine::entrance_scene(N5110 &lcd, Gamepad &gamepad)
 {
     int side = check_player_room_position();
@@ -72,6 +68,26 @@
     }
 }
 
+void RoomEngine::update_current_room()
+{
+    switch(check_player_room_position()) {
+        case 0 :
+            _room_y++;
+            break;
+        case 1 :
+            _room_x++;
+            break;
+        case 2 :
+            _room_y--;
+            break;
+        case 3 :
+            _room_x--;
+            break;
+        default :
+        break;
+    }
+}
+
 void RoomEngine::read_input(Gamepad &gamepad)
 {
     _L = gamepad.check_event(Gamepad::L_PRESSED);
@@ -129,6 +145,17 @@
     }
 }
 
+// Public Accessors
+
+int RoomEngine::get_room_x()
+{
+    return _room_x;
+}
+int RoomEngine::get_room_y()
+{
+    return _room_y;
+}
+
 // Private Mutators
 
 void RoomEngine::set_input(bool L, bool R, bool A, bool B, bool X, bool Y, float mapped_x, float mapped_y)
@@ -228,7 +255,7 @@
 {
     for (int i = 0; i < bullets_max; i++) {
         if (player->valid_bullets[i]) {
-            if (player->bullets_array[i]->out_of_bounds_check(room->get_current_map_2d())) {
+            if (player->bullets_array[i]->out_of_bounds_check(room->get_current_map_2d(), room->get_doorways())) {
                 player->valid_bullets[i] = false;
                 delete player->bullets_array[i];
             } else {
@@ -285,7 +312,7 @@
 
 void RoomEngine::move_player()
 {
-    player->move(mapped_coord.x, mapped_coord.y, room->get_current_map_2d());
+    player->move(mapped_coord.x, mapped_coord.y, room->get_current_map_2d(), room->get_doorways());
 }
 
 void RoomEngine::move_enemies()
@@ -294,7 +321,7 @@
     for (int i = 0; i < MAX_ENEMIES; i++) {
         if (room->valid_enemies[i]) {
             room->enemies[i]->update_prev_pos();
-            room->enemies[i]->move(player->get_pos_x(), player->get_pos_y(), room->get_current_map_2d());
+            room->enemies[i]->move(player->get_pos_x(), player->get_pos_y(), room->get_current_map_2d(), room->get_doorways());
         }
     }
     // Entity Collision Repulsion
@@ -310,7 +337,7 @@
 {
     for (int i = 0; i < bullets_max; i++) {
         if (player->valid_bullets[i]) {
-            player->bullets_array[i]->move(player->get_bullet_speed(), 0, 0);
+            player->bullets_array[i]->move(player->get_bullet_speed(), 0, 0, room->get_doorways());
         }
     }
 }
@@ -397,10 +424,10 @@
     draw_player(lcd);
     draw_enemies(lcd);
     draw_bullets(lcd);
+    room->draw_room_overlay(lcd);
     if (_L) {
         draw_health(lcd);
     }
-    room->draw_room_overlay(lcd);
 }
 
 void RoomEngine::draw_player(N5110 &lcd)