Sponsored By

To build or not to build (a level editor)

Sometimes creating a level editor can be a waste of time. Here I describe an experience using Inkscape to develop the levels of Gravity Maze

Francisco Tufro, Blogger

February 17, 2011

2 Min Read

GMgameplay

For the last few weeks I’ve been working on Gravity Maze a game/prototype that uses the idea of gravitational forces moving an avatar to solve mazes.

The goal for this game was getting it done quickly and reusing as much code as possible to reach a deadline for a contest.

One of the problems that arose was the interaction between the avatar and the maze. I had two ideas in my mind:

  1. Using a mask for the walls of the maze and detecting collision with a pixel-by-pixel technique.

  2. Using a physics engine.

I chose the physics engine for many reasons.

What did it mean? That each wall in the maze was part of a body, this way I could apply a rotation to the body and the whole maze would rotate. Also we got the avatar’s collisions and bouncing for free.

Then another problem arose: how to design levels.

There were a few options here too: creating the levels by hand, or developing a level editor.

I suddenly realized that both options would kill the project. Both were too complicated. Constructing a level editor is a long development task, and doing the levels by hand was a lot of work. Both were so time consuming that conflicted with the main goal of getting things done quickly.

inkscape

Then I recalled an old project I built in 2005. It was a regular polygon generator that used the n-th root of unity.

The interesting thing about that project was that it generated an SVG using the vertices from the equations.

The idea came to my mind: we could use Inkscape to design the levels! We only had to parse the XML (SVG files are XML files) and bingo!

I started to work at once and, after three hours, we had successfully finished an XML parser that loaded all the walls into the physics engine.

I must say that this simple idea made the difference between finishing the project on time and losing it. I think it’s a great option when there is little time.

If you plan to use this on your next game, be careful! Read the generated XML all the time since Inkscape uses matrix transforms when you move or rotate objects and groups. Either have your parser handle this or design the levels carefully taking care that no transformations are applied.

Another cool detail to have in mind is that Inkscape allows you to add custom attributes to objects.

I used them to define the maze’s start and finish. I'll be waiting for your comments and hope you still use FLOSS and let your head innovate on new ways to use existing stuff!

Read more about:

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

You May Also Like