Project-zero - implementing dynamic rooms 1
About the dynamic rooms, I started with a first implementation: an infinite one room space.
Using a simple tilemap(room) as a base for the level, a 3 times bigger “world” is created and is populated with the same exact tilemap, creating a grid of 3 by 3 rooms.
The character is allocated in the central room, then when the character moves and reach the red zone or the half of the mirror rooms the character is placed in the central room again using the same coordinates and the camera is properly set to follow the character at the same position, giving the illusion of an infinite world with the same room replicated.
This is how I implemented in phaser checking the X character position:
if(player1.x<limitWidth){ player1.x = width*3*tileWidth/2; game.camera.x = player1.x-game.camera.deadzone.x; } else if (player1.x>width*3*tileWidth-limitWidth){ player1.x = width*3*tileWidth/2; game.camera.x = player1.x-game.camera.deadzone.width-game.camera.deadzone.x; }
and this is a simple demonstration:
The next step is to add a space between rooms I called it transition zone














