Make a level editor
I’ve made a passable tileset and level generator for my game. Now, I’m going to make a level editor.
In the future, I’ll probably use a bit of procedural generation, but I want the ability to custom make certain levels and some things within levels. That’s where the level editor comes in.
How am I going to do this?
I’m going to make a web portal with js/html/css that will allow anybody to make a grid and fill it with preset tiles. It will have a button that will download the level as a JSON when they’re done.
Eventually, I'd like to put this web portal online so friends, family, and supporters can submit levels that might actually appear in the finished game.
As for the technical methods, It’s a matter of making the web page with HTML where each preset tile has a data attribute that tells it the code and color.
Then, I generate the grid based on the user’s input and add several event listeners to the cells.
Each cell will apply the currently selected color and code to itself when clicked or clicked and dragged over.
This is way quicker for me than using unity’s internal prefab placing methods.
Here is my JS file.
Eventually, I'd like to make a website for this game with a lot of cool information and features(to include this level editor incase fans want to submit potential levels), but for now I’m just going to put this into a browser emulator on codepen.io
Here is a link to the pen so you can play around with the editor if you wish.
How to use it :
The first input is the name of the file it will give you when you’re done.
Select the row and column count (best results if less than 100x100) and click generate.
Now that the base grid is on the screen, just click the tile preset you want and click and drag it over the tiles you’d like the preset to be placed.
The only rule thus far is any empty tiles within the grid must be zoned off with walls, and the up and down codes must be suffixed with a 3 digit number after “U” or “D” i.e. “U005” “D005”.
Allow me to demonstrate the level editor in action, and then I’ll put the level in my game, and it’s only going to take like 5 minutes because all this stuff I built was specifically designed to help make this process faster.
So all I have to do is keep track of some global modifiers like the up and down keywords and I can make levels very quickly.
Until next time