Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Files at this revision

API Documentation at this revision

Comitter:
el17sm
Date:
Sat May 04 15:39:20 2019 +0000
Parent:
28:98848e6a77a2
Child:
30:ec915d24d3e9
Commit message:
added Room complete;; started Floor engine;; ; To do:; Floor generation;; More enemies;; Bosses;; Title Screen;; Score;

Changed in this revision

Entity/Bullets/Bullets.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Bullets/Bullets.h Show annotated file Show diff for this revision Revisions of this file
Entity/Entity.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Entity.h Show annotated file Show diff for this revision Revisions of this file
Entity/Headless/Headless.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Headless/Headless.h Show annotated file Show diff for this revision Revisions of this file
Entity/Health/Health.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Health/Health.h Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Player.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Player.h Show annotated file Show diff for this revision Revisions of this file
Entity/Snake/Snake.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Snake/Snake.h Show annotated file Show diff for this revision Revisions of this file
Room/Room.cpp Show annotated file Show diff for this revision Revisions of this file
Room/Room.h Show annotated file Show diff for this revision Revisions of this file
RoomEngine/RoomEngine.cpp Show annotated file Show diff for this revision Revisions of this file
RoomEngine/RoomEngine.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Entity/Bullets/Bullets.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Bullets/Bullets.cpp	Sat May 04 15:39:20 2019 +0000
@@ -17,7 +17,7 @@
     direction = dir;
 }
 
-void Bullets::move(float speed, float unused, int * unused2)
+void Bullets::move(float speed, float unused, int * unused2, bool * unused3)
 {
     if (direction == 0) {
         position.y -= speed;
@@ -40,9 +40,9 @@
     return (int *) bullets_sprite;
 }
 
-bool Bullets::out_of_bounds_check(int * map)
+bool Bullets::out_of_bounds_check(int * map, bool * doorways)
 {
-    if (matrix_collision_test(position.x, position.y, map)) {
+    if (entity_to_map_collision_test(position.x, position.y, map, doorways)) {
         return true;
     }
     if ((0 > position.x) || (position.x > 84) || (0 > position.y) || (position.y > 48)) {
--- a/Entity/Bullets/Bullets.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Bullets/Bullets.h	Sat May 04 15:39:20 2019 +0000
@@ -10,10 +10,10 @@
     Bullets(float, float, int);
 
     // Functions
-    virtual void move(float, float, int * map);
+    virtual void move(float, float, int * map, bool * doorways);
     virtual int * get_frame();
     virtual void take_damage(int);
-    bool out_of_bounds_check(int * map);
+    bool out_of_bounds_check(int * map, bool * doorways);
 
 private:
     // Member Variable
--- a/Entity/Entity.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Entity.cpp	Sat May 04 15:39:20 2019 +0000
@@ -18,7 +18,7 @@
     prev_pos = position;
 }
 
-bool Entity::matrix_collision_test(float pos_x, float pos_y, int * map)
+bool Entity::entity_to_map_collision_test(float pos_x, float pos_y, int * map, bool * doorways)
 {      
     for (int j = pos_y; j < (int)pos_y + hitbox.height; j++) {
         for(int i = pos_x; i < (int)pos_x + hitbox.width; i++) {
@@ -26,12 +26,26 @@
             else if (*((map+j*screen_width)+i) == 1) {
                 return true;
             }
+            
+            // Checking if the player walks into a wall if no doorway on that side exists
+            else if ( !(*(doorways)) && (pos_y < 9) ) {
+                return true;
+            }
+            else if ( !(*(doorways+1)) && (pos_x + hitbox.width - 1 > 81) ) {
+                return true;
+            }
+            else if ( !(*(doorways+2)) && (pos_y + hitbox.width - 1 > 36) ) {
+                return true;
+            }
+            else if ( !(*(doorways+3)) && (pos_x < 2) ) {
+                return true;
+            }
         }
     }
     return false;
 }
 
-// mutators
+// Mutators
 
 void Entity::set_position(float x, float y)
 {
--- a/Entity/Entity.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Entity.h	Sat May 04 15:39:20 2019 +0000
@@ -44,13 +44,13 @@
 
 public:
     // Function
-    virtual void move(float, float, int * map) = 0; // movement control and miscellaneous updates
+    virtual void move(float, float, int * map, bool * doorways) = 0; // movement control and miscellaneous updates
     virtual int * get_frame() = 0;
     virtual void take_damage(int) = 0;
-    bool matrix_collision_test(float pos_x, float pos_y, int * map);
     void undo_move_x(bool);
     void undo_move_y(bool);
     void update_prev_pos();
+    bool entity_to_map_collision_test(float pos_x, float pos_y, int * map, bool * doorways);
 
     // Mutator
     void set_position(float x, float y);
--- a/Entity/Headless/Headless.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Headless/Headless.cpp	Sat May 04 15:39:20 2019 +0000
@@ -24,7 +24,7 @@
     velocity = 0.25;
 }
 
-void Headless::move(float player_x, float player_y, int * map)
+void Headless::move(float player_x, float player_y, int * map, bool * doorways)
 {
     std::complex<double> pos_diff(player_x - position.x, player_y - position.y); // defining difference in position as a vector
     position.x += velocity * pos_diff.real() / std::abs(pos_diff);
@@ -40,8 +40,8 @@
         face = 3;
     }
 
-    undo_move_x(matrix_collision_test(position.x, prev_pos.y, map));
-    undo_move_y(matrix_collision_test(prev_pos.x, position.y, map));
+    undo_move_x(entity_to_map_collision_test(position.x, prev_pos.y, map, doorways));
+    undo_move_y(entity_to_map_collision_test(prev_pos.x, position.y, map, doorways));
 
     if (frame.number < frame.max) {
         frame.count++;
--- a/Entity/Headless/Headless.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Headless/Headless.h	Sat May 04 15:39:20 2019 +0000
@@ -10,9 +10,9 @@
     Headless(float, float);
 
     // Functions
-    virtual void move(float, float, int * map);
+    virtual void move(float player_x, float player_y, int * map, bool * doorways);
     virtual int * get_frame();
-    virtual void take_damage(int);
+    virtual void take_damage(int damage);
 
 };
 
--- a/Entity/Health/Health.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Health/Health.cpp	Sat May 04 15:39:20 2019 +0000
@@ -18,7 +18,7 @@
     sprite_size.offset_y = 0;
 }
 
-void Health::move(float unused, float unused1, int * unused2)
+void Health::move(float unused, float unused1, int * unused2, bool * unused3)
 {
     
 }
--- a/Entity/Health/Health.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Health/Health.h	Sat May 04 15:39:20 2019 +0000
@@ -9,7 +9,7 @@
     Health(float, float);
 
     // Functions
-    virtual void move(float, float, int * map);
+    virtual void move(float, float, int * map, bool * doorways);
     virtual int * get_frame();
     virtual void take_damage(int);
 
--- a/Entity/Player/Player.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Player/Player.cpp	Sat May 04 15:39:20 2019 +0000
@@ -34,19 +34,14 @@
 
 Player::~Player()
 {
-    for (int i = 0; i < bullets_max; i++) {
-        if (valid_bullets[i]) {
-            delete bullets_array[i];
-            valid_bullets[i] = false;
-        }
-    }
+    delete_bullets();
 }
 
 // Accessors
 int Player::get_bullet_speed()
 {
     return _bullet_speed;
-};
+}
 int Player::get_hearts_width()
 {
     return 9;
@@ -61,12 +56,12 @@
 }
 
 // Functions
-void Player::move(float mapped_x, float mapped_y, int * map)
+void Player::move(float mapped_x, float mapped_y, int * map, bool * doorways)
 {
-    if(!matrix_collision_test(position.x + velocity*mapped_x, position.y, map)) {
+    if(!entity_to_map_collision_test(position.x + velocity*mapped_x, position.y, map, doorways)) {
         position.x += velocity*mapped_x;
     }
-    if(!matrix_collision_test(position.x, position.y - velocity*mapped_y, map)) {
+    if(!entity_to_map_collision_test(position.x, position.y - velocity*mapped_y, map, doorways)) {
         position.y -= velocity*mapped_y;
     }
     moving = false;
@@ -106,6 +101,15 @@
         hp = 5;
     }
 }
+void Player::delete_bullets()
+{
+    for (int i = 0; i < bullets_max; i++) {
+        if (valid_bullets[i]) {
+            delete bullets_array[i];
+            valid_bullets[i] = false;
+        }
+    }
+}
 
 int * Player::get_frame()
 {
--- a/Entity/Player/Player.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Player/Player.h	Sat May 04 15:39:20 2019 +0000
@@ -18,23 +18,25 @@
     
 public:
     // Constructors
-    Player(float, float);
+    Player(float pos_x, float pos_y);
     // Deconstructors
     ~Player();
 
-    // Functions
-    virtual void move(float, float, int * map);
-    virtual int * get_frame();
-    virtual void take_damage(int);
-    void buttons(bool, bool, bool, bool);
+    // Accessors
+    int get_bullet_speed();
+    
     int get_hearts_width();
     int get_hearts_height();
     int * get_hearts_sprite();
+    
+    // Functions
+    virtual void move(float, float, int * map, bool * doorways);
+    virtual void take_damage(int damage);
+    virtual int * get_frame();
+    void delete_bullets();
+    void buttons(bool button_A, bool button_B, bool button_Y, bool button_X);
 
-    // accessors
-    int get_bullet_speed();
-
-    // variables
+    // Variables
     Bullets *bullets_array[bullets_max];
     bool valid_bullets[bullets_max];
     
--- a/Entity/Snake/Snake.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Snake/Snake.cpp	Sat May 04 15:39:20 2019 +0000
@@ -12,14 +12,14 @@
     face = 0;
     hp = 4;
     attack = 1;
-    hitbox.width = 6;
-    hitbox.height = 5;
+    hitbox.width = 4;
+    hitbox.height = 7;
     position.x = pos_x;
     position.y = pos_y;
     sprite_size.width = 6;
-    sprite_size.height = 9;
-    sprite_size.offset_x = 0;
-    sprite_size.offset_y = 4;
+    sprite_size.height = 12;
+    sprite_size.offset_x = 1;
+    sprite_size.offset_y = 6;
     frame.count = 0;
     frame.number = 0;
     frame.max = 6;
@@ -48,7 +48,7 @@
 }
 
 // Functions
-void Snake::move(float player_x, float player_y, int * map)
+void Snake::move(float player_x, float player_y, int * map, bool * doorways)
 {
     std::complex<double> pos_diff(player_x - position.x, player_y - position.y); // defining difference in position as a vector
     velocity = velocity_pattern[_velocity_index]; // Creating slithering effect, changing velocity of movement
@@ -86,8 +86,8 @@
         update_hitbox(7, 4, 12, 7, 0, 4, 4);
     }
 
-    undo_move_x(matrix_collision_test(position.x, prev_pos.y, map));
-    undo_move_y(matrix_collision_test(prev_pos.x, position.y, map));
+    undo_move_x(entity_to_map_collision_test(position.x, prev_pos.y, map, doorways));
+    undo_move_y(entity_to_map_collision_test(prev_pos.x, position.y, map, doorways));
 
     frame.count++;
     if (frame.count >= 10) {
--- a/Entity/Snake/Snake.h	Thu May 02 21:30:49 2019 +0000
+++ b/Entity/Snake/Snake.h	Sat May 04 15:39:20 2019 +0000
@@ -10,7 +10,7 @@
     Snake(float, float);
 
     // Functions
-    virtual void move(float, float, int * map);
+    virtual void move(float, float, int * map, bool * doorways);
     virtual int * get_frame();
     virtual void take_damage(int);
 
--- a/Room/Room.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/Room/Room.cpp	Sat May 04 15:39:20 2019 +0000
@@ -3,27 +3,24 @@
 // Constructor
 Room::Room(int no_of_enemies)
 {
-    for (int i = 0; i < MAX_ENEMIES; i++)
+    for (int id = 0; id < MAX_ENEMIES; id++)
     {
-        valid_enemies[i] = i < no_of_enemies;
-        if (i < no_of_enemies) {
-            enemies_type[i] = rand() % 2;
+        valid_enemies[id] = id < no_of_enemies;
+        if (id < no_of_enemies) {
+            enemies_type[id] = rand() % 2;
+            _enemy_coord[id][0] = 11 + (rand() % 60);
+            _enemy_coord[id][1] = 18 + (rand() % 19);
         }
     }
+    
     _room_type = 0;
-    for (int layer = 0; layer < 3; layer++) {
-        for (int i = 0; i < screen_width; i++) {
-            for (int j = 0; j < screen_height; j++) {
-                _current_map[layer][j][i] = level_map[_room_type][layer][j][i];
-            }
-        }
-    }
     _doorways[0] = true;
     _doorways[1] = true;
     _doorways[2] = true;
     _doorways[3] = true;
 }
 
+// Deconstructor
 Room::~Room()
 {
     terminate();
@@ -31,27 +28,31 @@
 
 // Accessors
 int * Room::get_current_map_2d(){
-    return ((int *) _current_map[0]);
+    return ((int *)level_map[_room_type][0]);
+}
+
+bool * Room::get_doorways(){
+    return (bool *)_doorways;
 }
 
 // Functions
 void Room::load()
 {
-    for (int i = 0; i<4; i++) {
-        if (!_doorways[i]){
-            overlap_wall(i); // Drawing walls on current map
-        }
-    }
-    for (int i = 0; i < MAX_ENEMIES; i++) {
-        if (valid_enemies[i]) {
-            switch(enemies_type[i]){
+    for (int id = 0; id < MAX_ENEMIES; id++) {
+        if (valid_enemies[id]) {
+            switch(enemies_type[id]){
                 case 0 :
-                    enemies[i] = new Headless(20, 20);
+                    enemies[id] = new Headless(_enemy_coord[id][0], _enemy_coord[id][1]);
                     break;
                 case 1 :
-                    enemies[i] = new Snake(20, 30);
+                    enemies[id] = new Snake(_enemy_coord[id][0], _enemy_coord[id][1]);
                     break;
             }
+//            for every enemy
+//            if (collision) {
+//                relocate enemy
+//                goto back
+//            }
         }
     }
 }
@@ -67,45 +68,45 @@
 
 void Room::draw_room(N5110 &lcd)
 {
-    lcd.drawSprite(0, 0, screen_height, screen_width, (int *)_current_map[1]); // drawing 3d map
+    lcd.drawSprite(0, 0, screen_height, screen_width, (int *)level_map[_room_type][1]); // drawing 3d map
+    //draw_walls(lcd);
+    
+}
+
+void Room::draw_walls(N5110 &lcd)
+{
+    if(_doorways[0]) { // N
+        lcd.drawSprite(36, 0, 12, 10, (int *)wall_n);
+    }
+    if(_doorways[1]) { // E
+        lcd.drawSprite(81, 15, 3, 11, (int *)wall_x[0]);
+    }
+    if(_doorways[2]) { // S
+        lcd.drawSprite(36, 45, 12, 3, (int *)wall_s);
+    }
+    if(_doorways[3]) { // W
+        lcd.drawSprite(0, 15, 3, 11, (int *)wall_x[1]);
+    }
 }
 
 void Room::draw_room_overlay(N5110 &lcd)
 {
-    lcd.drawSpriteTransparent(0, 0, screen_height, screen_width, (int *)_current_map[2]);
-}
-
-void Room::overlap(int x, int y, int width, int height, int * object, int * map)
-{
-    for(int i = 0; i < width; i++) {
-        for (int j = 0; j < height; j++) {
-            *((map+(y+j)*screen_width)+(x+i)) = *((object+j*width)+i);
-        }
-    }
+    lcd.drawSpriteTransparent(0, 0, screen_height, screen_width, (int *)level_map[_room_type][2]); // drawing 3d map overlay
+    //draw_walls_overlay(lcd);
 }
 
-void Room::overlap_wall(int side)
+void Room::draw_walls_overlay(N5110 &lcd)
 {
-    switch(side) {
-        case 0 : // N
-            overlap(36, 0, 12, 10, (int *)wall_n[0], (int *)_current_map[0]);
-            overlap(36, 0, 12, 10, (int *)wall_n[1], (int *)_current_map[1]);
-            overlap(36, 0, 12, 10, (int *)wall_n[1], (int *)_current_map[2]);
-            break;
-        case 1 : // E
-            overlap(81, 22, 3, 11, (int *)wall_x[0], (int *)_current_map[0]);
-            overlap(81, 15, 3, 11, (int *)wall_x[0], (int *)_current_map[1]);
-            overlap(81, 15, 3, 11, (int *)wall_x[0], (int *)_current_map[2]);
-            break;
-        case 2: // S
-            overlap(36, 45, 12, 3, (int *)wall_s[0], (int *)_current_map[0]);
-            overlap(36, 45, 12, 3, (int *)wall_s[1], (int *)_current_map[1]);
-            overlap(36, 45, 12, 3, (int *)wall_s[1], (int *)_current_map[2]);
-            break;
-        case 4 : // W
-            overlap(0, 22, 3, 11, (int *)wall_x[1], (int *)_current_map[0]);
-            overlap(0, 15, 3, 11, (int *)wall_x[1], (int *)_current_map[1]);
-            overlap(0, 15, 3, 11, (int *)wall_x[1], (int *)_current_map[2]);
-            break;
+    if(_doorways[0]) { // N
+        lcd.drawSpriteTransparent(36, 0, 12, 10, (int *)wall_n);
+    }
+    if(_doorways[1]) { // E
+        lcd.drawSpriteTransparent(81, 15, 3, 11, (int *)wall_x[0]);
+    }
+    if(_doorways[2]) { // S
+        lcd.drawSpriteTransparent(36, 45, 12, 3, (int *)wall_s);
+    }
+    if(_doorways[3]) { // W
+        lcd.drawSpriteTransparent(0, 15, 3, 11, (int *)wall_x[1]);
     }
 }
\ No newline at end of file
--- a/Room/Room.h	Thu May 02 21:30:49 2019 +0000
+++ b/Room/Room.h	Sat May 04 15:39:20 2019 +0000
@@ -1,26 +1,28 @@
 #ifndef ROOM_H
 #define ROOM_H
 #include "sprites.h"
+
 #include "Entity.h"
 #include "Player.h"
 #include "Headless.h"
 #include "Snake.h"
+
 #include "N5110.h"
 
 #define MAX_ENEMIES 10
 
 class Room // contains the type of room, number of enemies inside it, the doorways existing in the room, functions to spawn enemies
 {
-    private:
+private:
     bool _doorways[4];
     int _room_type;
-    int _current_map[3][48][84];
+    int _enemy_coord[MAX_ENEMIES][2]; //  _enemy_coord[EnemyID][x/y]
     
     // Functions
-    void overlap(int x, int y, int width, int height, int * object, int * map);
-    void overlap_wall(int side);
+    void draw_walls(N5110 &lcd);
+    void draw_walls_overlay(N5110 &lcd);
     
-    public:
+public:
     // Constructors
     Room(int no_of_enemies);
     // Deconstructors
@@ -28,6 +30,7 @@
     
     // Accessors
     int * get_current_map_2d();
+    bool * get_doorways();
     
     // Functions
     void load();
@@ -70,44 +73,23 @@
     }
 };
 
-const int wall_n[2][10][12] = { // [2d/3d][Size_Y][Size_X]
-    {   // N
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {1,1,1,1,1,1,1,1,1,1,1,1,},
-    },
-    {   
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {1,1,1,1,1,1,1,1,1,1,1,1,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {1,1,1,1,1,1,1,1,1,1,1,1,},
-    },
+const int wall_n[10][12] = { // [Size_Y][Size_X] 
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {1,1,1,1,1,1,1,1,1,1,1,1,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {0,0,0,0,0,0,0,0,0,0,0,0,},
+    {1,1,1,1,1,1,1,1,1,1,1,1,},
 };
 
-const int wall_s[2][3][12] = { // [2d/3d][Size_Y][Size_X]
-    {
-        {1,1,1,1,1,1,1,1,1,1,1,1,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-        {0,0,0,0,0,0,0,0,0,0,0,0,},
-    },
-    {
-        {1,1,1,1,1,1,1,1,1,1,1,1,},
-        {2,2,2,2,2,2,2,2,2,2,2,2,},
-        {2,2,2,2,2,2,2,2,2,2,2,2,},
-    },
+const int wall_s[3][12] = { // [Size_Y][Size_X]
+    {1,1,1,1,1,1,1,1,1,1,1,1,},
+    {2,2,2,2,2,2,2,2,2,2,2,2,},
+    {2,2,2,2,2,2,2,2,2,2,2,2,},
 };
 
 #endif
\ No newline at end of file
--- 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)
--- a/RoomEngine/RoomEngine.h	Thu May 02 21:30:49 2019 +0000
+++ b/RoomEngine/RoomEngine.h	Sat May 04 15:39:20 2019 +0000
@@ -1,28 +1,35 @@
 #ifndef ROOMENGINE_H
 #define ROOMENGINE_H
 #include "N5110.h"
+#include "Gamepad.h"
+
 #include "Player.h"
-#include "Bullets.h"
+#include "Health.h"
 #include "Room.h"
-#include "Gamepad.h"
+
 #include "sprites.h"
-#include "Health.h"
+
 
 class RoomEngine
 {
 public:
     RoomEngine();
     ~RoomEngine();
-    void init(Player &current_player, Room &current_room);
-    void save_room(Room &current_room);
+    void load(Player &current_player, Room *current_room);
     void entrance_scene(N5110 &lcd, Gamepad &gamepad);
     void exit_scene(N5110 &lcd, Gamepad &gamepad);
+    void update_current_room();
+    
     void read_input(Gamepad &gamepad);
     void update();
     void render(N5110 &lcd, Gamepad &gamepad);
     bool check_player_death();
     int check_player_room_position();
     
+    // Accessor
+    int get_room_x();
+    int get_room_y();
+    
 private:
     bool _L;
     bool _R;
@@ -32,6 +39,9 @@
     bool _Y;
     Vector2D mapped_coord;
     
+    int _room_x;
+    int _room_y;
+    
     Room *room;
     Player *player;
     
--- a/main.cpp	Thu May 02 21:30:49 2019 +0000
+++ b/main.cpp	Sat May 04 15:39:20 2019 +0000
@@ -21,8 +21,8 @@
 #include "RoomEngine.h"
 
 #define INSIDE 4
-#define MAX_ROOMS_MAP_X 10
-#define MAX_ROOMS_MAP_Y 10
+#define MAX_ROOMS_MAP_X 11
+#define MAX_ROOMS_MAP_Y 11
 
 // Objects
 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
@@ -34,42 +34,58 @@
 // Functions
 int main()
 {
-    // initialize
+    // Initialize
     lcd.init();
     lcd.setContrast(0.5);
     gamepad.init();
-    Player player(39, 27);
     
-    while(1) { // gameloop
+    while(1) { // Gameloop
+        srand(2);
+        Player player(39, 27);
         RoomEngine room_engine;
-        Room room(2);
+        while(1) {  // Floor Loop 
+            Room *rooms[MAX_ROOMS_MAP_Y][MAX_ROOMS_MAP_X];
+            
+            for (int i = 0; i < MAX_ROOMS_MAP_X; i++) {
+                for (int j = 0; j < MAX_ROOMS_MAP_Y; j++) {
+                    rooms[j][i] = new Room(2);
+                }
+            }
+
             // Rooms Generation
-        while(player.get_hp() > 0) {  // Room Loop 
-            while(1) {
-                room.load();
-                room_engine.init(player, room);
+            while(1) {  // Room Loop
+                rooms[room_engine.get_room_y()][room_engine.get_room_x()]->load();
+                room_engine.load(player, rooms[room_engine.get_room_y()][room_engine.get_room_x()]);
                 
                 room_engine.entrance_scene(lcd, gamepad);
                 while(room_engine.check_player_room_position() == INSIDE) {  // Room actions
                     room_engine.read_input(gamepad);
                     room_engine.update();
                     room_engine.render(lcd, gamepad);
+                    if  (player.get_hp() <= 0) {
+                        goto gameover;
+                    }
                 }
                 room_engine.exit_scene(lcd, gamepad);
-                room.unload();
+                rooms[room_engine.get_room_y()][room_engine.get_room_x()]->unload();
+                player.delete_bullets();
+                room_engine.update_current_room();
             }
         }
-        lcd.clear();
-        lcd.setContrast(0.5);
-        lcd.printString("Game Over", 0, 0);
-        lcd.printString("Retry?", 0, 1);
-        lcd.refresh();
-        room_engine.~RoomEngine();
-        wait(0.05);
-        while(!gamepad.check_event(Gamepad::A_PRESSED)) {
-        }
-        wait(0.05);
-        while(gamepad.check_event(Gamepad::A_PRESSED)) {
+        gameover: {
+            lcd.clear();
+            lcd.setContrast(0.5);
+            lcd.printString("Game Over", 0, 0);
+            lcd.printString("Retry?", 0, 1);
+            lcd.refresh();
+            room_engine.~RoomEngine();
+            player.~Player();
+            wait(0.05);
+            while(!gamepad.check_event(Gamepad::A_PRESSED)) {
+            }
+            wait(0.05);
+            while(gamepad.check_event(Gamepad::A_PRESSED)) {
+            }
         }
     }
 }
\ No newline at end of file