Sponsored By

Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs.

This is the gripping TRUE STORY of failed prototypes, wasted time, custom level editors… and UNEXPECTED SALVATION at the hands of the HUMBLE SPREADSHEET.

Tim Conkling, Blogger

June 16, 2015

4 Min Read

(Reposted from my game development blog)

A 2D Level Editor in 30 Seconds

This is the gripping TRUE STORY of failed prototypes, wasted time, custom level editors… and UNEXPECTED SALVATION at the hands of the HUMBLE SPREADSHEET.

(Also it does literally have a recipe for creating a custom 2D level editor in like under a minute.)

Level editing: the artisinal approach

A couple years ago, before beginning work on Antihero, my current project, I was prototyping a 2D action game.*

When the core systems were in place, it was time to start building some test levels, so I got out my text editor and wrote some XML.

Level editing: the “professional” approach

For obvious reasons, writing levels by hand is not a scalable process:

So my next step was to build an in-engine editor. I banged out a really basic one. I’d done this for a bunch of projects before, but even so, it took about 3 weeks, because I am slow.

It lacked basic features like undo/redo and copy/paste, it had bugs, and its UI was terrible compared to a “real” tool like Unity, UnrealEd, etc - but at least it was better than hand-edited XML.

But! None of that mattered… because a short while later I shelved the game. It was taking too long to find the fun, and no amount of editor fanciness was going to help.

Level editing: the really really fast approach

So: onto the next prototype - another 2D game. (This one would eventually become Antihero.)

With the core systems in place, it was again time to build some levels. This time, I was determined not to spend weeks on an editor for a game I might throw out anyway.

In the interest of ruthless efficiency, I scavenged for existing tools I might leverage. My goal was to write as little code as possible. It occurred to me that spreadsheets were 2D grids, so I pulled out Excel and fiddled with the cell layout a bit.

I picked a handful of symbols to represent game objects, designed a prototype level for my game, and spent a little while writing a script to convert CSV files into my XML level format.

Excel was immediately more useful than my previous custom editor. It has many of the qualities you’d want: undo/redo, copy and paste, zoom in/out; and also some unexpectedly useful features, like find-and-replace, which I frequently used to count the number of a specific entity type. And it’s fast and stable - and reusable. (I reused all of this in a game jam a short while later - this time for a 2D platformer. Very different game; exact same editor.)

Of course, Antihero eventually outgrew its spreadsheet editor and grew its own custom big-kid editor on its way to eventual procedural level generation. But by the time the “real” editor became necessary, the game design was much more solid, its important features were nailed down, and I knew it was a project with legs.

A 2D editor in 30 seconds

The code that parses CSV files is, as you’d expect, trivial. You can get my Python script here.

This is the boilerplate for a custom editor using the csv_grid code from above:

The “editor goes here” game-specific bit is just a series of if-else statements that loops over the symbols in the grid, constructs a representation of the board in the appropriate format -- in my case, XML -- and prints it back out to the terminal, suitable for redirecting to a file. (You could also just write the CSV parser directly in your game and skip this intermediate step altogether.)

And that’s it!

There are good 2D editor tools out there, like Tiled. But if you’re rapidly prototyping, it makes sense graduate to these - or a custom editor - after prototyping has proved out the core game.

* There’s a lot of “borrowed” art in this post’s screenshots. Thanks for not suing me, Binding of Isaac, Hero Academy, Warcraft 2, etc!

(If you’re interested in running your own thieves’ guild, you can read more about Antihero, my in-development game, or follow me on Twitter.)

Read more about:

Featured Blogs

About the Author(s)

Daily news, dev blogs, and stories from Game Developer straight to your inbox

You May Also Like