Content creation can be one of the most time-consuming parts of game development, which is why building a level editor can be so useful. In this article, I'll share my tips for creating an efficient level editor, and explain how using this kind of tool has sped up my workflow.
Here's the scenario: you've spent months working on your game and it's finally starting to come together. The codebase is strong, and you have come to the point where you can start creating levels for your game.
There's only one problem - your level file looks like this:
Object Texture rocks4 Position 78 540 Rotation 0 Scale 1 1 Color 255 255 255 255 ScrollSpeed 1 1 CustomProperties End End Object Texture grass1 Position 60 450 Rotation 0 Scale 1 1 Color 255 255 255 255 ScrollSpeed 1 1 CustomProperties End End Object Texture grass2 Position 61 459 Rotation 0 Scale 1 1 Color 255 255 255 255 ScrollSpeed 1 1 CustomProperties End End
Yuck. Imagine trying to create entire levels like this. The process would be incredibly slow and time-consuming - not to mention frustrating. The problem is that it is very difficult to edit something that is meant to be seen. What, then, can be done about this? The answer, surprisingly, lies in the context of the problem itself.
Levels are a form of visual communication. Players aren't looking at text files, they're looking at images, sprites, animations, and so on. Think of an painter: Picasso didn't make his paintings by inserting RGB values per pixel into a computer. He made his paintings by, well, painting them. To apply the same logic to level design, we should create a tool that will allow us to visually edit such levels - a level editor.
One of the most important advantages to having a level editor is the convenience of WYSIWYG ("What You See Is What You Get" - what you see in the editor is what you'll get in the game). As described above, it's much easier to design when you can see what you are editing.
Another advantage is that it allows for quicker and more efficient design iteration. The process of level design can be broken down to a simple flowchart like this:
It is crucial that you can move seamlessly between the Design and Test phases, as this allows for quicker iterations and less time spent overall.
The final reason for having a level editor is that it makes the job of level design much less technical. This is especially relevant when working in a team: imagine sending the above text file to the artists and telling them to design levels in that format!
Good communication - both verbal and visual - is essential within a team, and a level editor can make non-technical designers' lives a whole lot easier, as well as removing a potential communication barrier between them and the developers.
So, in summary, the three most important reasons for having a level editor are that they allow you to:
- Design visually
- Iterate more efficiently
- Be less technical
Why Not Use an Existing Editor?
You might be asking why you would want to make your own editor when there are already so many freely available to use - and I'm not going to lie, there are some great editors out there.
Here are a few I know of for 2D games:
There are advantages and disadvantages to using a generic, existing editor. It's likely to be robust and well-maintained, but it knows nothing about your game, so you might have to do clever tricks in order for it to interact correctly with your game. This digs into iteration time and can result in a lot more unnecessary time spent during content creation.
Also, you have to learn how to use it, whereas if you used your own editor, you obviously know everything about it already.
Here's my personal list of pros and cons for each type of editor:
- Pro: Robust and well-maintained
- Pro: Less code for you to write
- Con: Have to learn how to use
- Con: Might have limitations with your game's design
- Pro: Tailors exactly to how your game works
- Pro: You already know how to use it
- Con: More development time to build the editor
It's up to you, but for the sake of this article, I'm going to focus on designing your own.
Next, I'll share my top tips for creating a robust and effective level editor.
Tip 1: Reuse Code
You might cringe at the fact that you'll have to write more code for a level editor. But why not make this process as painless as possible?
If you're at the point where you need a level editor, you probably already have a bit of structure to your game architecture (classes, interfaces, inheritance, etc.). Reuse this code! If you already have a bunch of classes for drawing and updating stuff for the game, there's no need to rewrite it for the editor. In other words, DON'T write a separate engine for the editor. Besides letting you reuse game code, this will help you reduce the gap between how the level looks in your editor and how it looks in the game.
There are two approaches to implementing a level editor: you can have it in-game, or build it as an external app. Again, both approaches have their ups and downs.
The in-game editor would essentially eliminate the gap between designing and testing, but it would require a lot more GUI work, for instance. The external editor could use GUI libraries and have robust features, but the design-test iteration would be slightly longer, given the fact that you would have to constantly switch between two different apps.
I personally prefer the first approach because I think it feels the most natural, and I really like the convenience of switching between designing and testing instantaneously.
Tip 2: Favor Efficiency Over Aesthetics
Remember, this editor is for you (or your level designer, if working in a team). There's no need to make it look pretty. In fact, that's probably a waste of time, unless you plan to distribute the editor. Instead, focus on making a functional level editor as fast as possible so you can get to content creation. (Later on, when your game is nearing completion, you can consider things like "beautifying" the editor.)
This may seem obvious, but shortcuts are your friends. Have a key binded to every action you think you might do. I'm serious; doing this will save you so much time when designing. For example, pressing 'C' in the level editor of my game creates a duplicate of the currently selected object. It's simple, but immensely useful and saves a lot of time.
As an example, let me show you the editor of my currently in-development game, Mori. Here's a tile that I have rotated and scaled:
All I have to do is press 'C' and... voila!
Tip 3: Remember It's for Your Game
This is the beautiful part of designing your own editor: it can do anything you want it to do.
Every game is different; some games require extensive scripting, while others may involve intricate AI behaviors. All of these can be integrated into the editor. Imagine being able to add an enemy with a certain behavior just by pressing a few keys in the editor. Now imagine trying to do that same thing by adding code to a scripting file. Which seems more efficient?
Tip 4: Make Your Life Easier
There are certain conventions that we have become accustomed to when using applications. These include conveniences like undo/redo, copy/paste, warning messages, and so on. If you plan properly, you can implement all of these into your editor without much additional work. Trust me, you'll thank yourself in the future if you have these.
Another feature that can make your life easier is being able to test levels without saving the file to disk. This makes the design-test process so much easier. My game uses a game state management system, so I have two separate "screens" for gameplay and editing.
From within the game, I hit a key to enter the editor. The editor is passed the level object, which can then be manipulated from within the editor. From there, I have two options: I can save the level to disk, or I can hit a certain key and pass the level object back to the gameplay screen. This allows me to test the level right away without the fear of overwriting my old changes.
In short, a level editor is a worthwhile investment in the game development process. It allows for the visual design of levels, faster iteration times, and a lower technical skill requirement for designers.
I hope you found this article interesting and useful. Thanks for dropping by!
Subscribe below and we’ll send you a weekly email summary of all new Game Development tutorials. Never miss out on learning about the next big thing.Update me weekly
Envato Tuts+ tutorials are translated into other languages by our community members—you can be involved too!Translate this post