This is the final step--the game has all the required information, it just needs to know which room to move the player to when they leave the layout. To do this, you need to do four things.
- If the player is outside the layout, then (trigger once):
- If the player's X is greater than (a number near the right edge), then
- add 1 to roomX, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's X to (a number near the layout's left edge)
- If the player's X is less than (a number near the left edge), then
- subtract 1 from roomX, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's X to (a number near the layout's right edge)
- If the player's Y is less than (a number near the top edge), then
- subtract 1 from roomY, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's Y to (a number near the layout's bottom edge)
- If the player's Y is greater than (a number near the bottom edge), then
- add 1 to roomY, set roomName to "Array.At(roomX,roomY,0)", go to layout RoomName, set player's Y to (a number near the layout's top edge)
What this does is makes it so that when the player leaves the layout, the edge they left from determines where they will end up. Leaving from the top edge will cause roomY to decrease, leaving from the right edge will cause roomX to increase, etc.
Remember that in Construct 3, all coordinates are in the fourth graph quadrant, meaning that X increases from left to right but Y increases from top to bottom instead of bottom to top.