I was thinking about Dungeons and dungeon generation and also about how to give players the ability to make their own Dungeons and share them with each other.
Well a map can be saved as a 2D matrix, I have even done it with a list of values or 1D matrix.
Here you can see an example I made for a platformer, using a 1D matrix to make square levels (you can edit the level during runtime, play it, save it and load it):
But how does someone edit, share and transfer those easily? How could I make a quick editor or even edit maps outside the game? How could I send new maps to my players fast and make sure they don’t break the game no matter the version?
Well an image is a matrix and we can have RGBA info, so we can hold multiple values in one image for one map and also edit and also transfer them easily.
What do we see here:
This is basically a couple of hours worth of work as a proof of concept.
I made a script that takes an image as input, identifies what each pixel represents and instantiates it. It makes levels of arbitrary sizes, it can spawn empty, floors, walls, columns, enemies and the player.
I also wanted to be able to make sure to use NavMesh and even though Unity is going to add runtime generation in 2017, this was done to prove that if you don’t fight Unity you can even do things it’s not supposed to do.
So the enemies have a NavMesh Agent and the NavMesh is carved using NavMesh Obstacles and as you can see from the delayed generation mode below they can follow you upon spawning even if the level hasn’t finished yet.
I added a delayed generation version because generation was so fast I couldn’t see my work in action, it was hit play, see level, so I put my code in a coroutine and added a small delay to see things being built.
What will I do with this:
I don’t think I am going to use it for Dominus Infernus, I have another game idea it might be more useful for, since in Dominus Infernus I want a higher standard of graphics, which will be achieved using 3D pre-rendered backgrounds.