slembcke
Marching Squares?

One issue we have been running into as part time developers is that we don’t always have the time to build the tools that we’d like in order to build our games. Level editors in particular can be tricky if your game needs a non-trivial one where you can’t just define levels in text files.
The solution we are going to try to allow us to easily generate intricate levels is an algorithm called marching squares. Basically it lets us turn a black and white image into a collection of lines that trace the edge. The image above was generated by tracing a 512×512 image to generate over 13,000 tiny line segments (shown in grey). As that is far too many to use in a game, I run a simplification algorithm to generate the red lines consisting of 1400 line segments.
While there are still a few bugs (half way down on the right side 🙁 ), I’m pretty happy with the results so far. Hopefully this will allow us to make far more interesting games given our limited resources!