I have been working on this for 10 days now and I wanted to share it with everyone!
The idea is simple: generate a new room as the player choose in which direction he wants to go. And of course the mini map.
Ok it seems to be a really common thing but the tricky part was to make the new rooms fit the already created ones. So the directions are always logical and possible: you can't join a room if there is no entrance to it.
Here was my method:
1 • In and Out Directions
I need to check the actual in/out direction on the screen and create or load the next room as the player touch it.
2 • Create Boards
If the next room doesn't exists, it creates a new one according to the table NextBoardCreation.json loaded in an array. The table is big as there is a lot of possibilities as the player wants to go up, left, down or right. I also needed to check if the are already created rooms touching the next one.
My table fro the rooms creation
3 • Load Boards
If the room exist already, I want it to be saved on an array. So it can be charged again if the player comes back in the room.
4 • Map & Type of Board to create
This was the big part of the work in the end.Beside showing the player his actual position, it helps for creating the next rooms with 2 types of detectors: the first range are the ones very close of the actual room (up,left,down,right) and the second range are there to check if there are actually some other rooms existing around and give information about it, like if there is an entrance to those rooms.
You can access the file here:
dropbox.com/s/5w9ad59vq7cd6lt/LevelGeneratorFinal.c3p
As you can see, it works pretty well.
Of course I'm sure it's not perfect. I'm not a dev and maybe there is a better method to do it or to optimise and reduce number of lines of code.
I will be happy to hear your suggestions or impressions about it. And there is also more to do to make it even better, so feel free to custom it!