The death of a hand-rolled mapping system

I started this project with the conceit that I was going to write my own, custom mapping system using PNG files. I got the idea watching this video by notch a couple years ago:

You can see how I became so enamored of the concept. What could be easier than drawing your levels as PNG images, pixel by pixel? Also, it seemed like it would be pretty fun to code up. And it was!

All progress videos so far use this system of level creation / editing. Here’s what the map from the last post looks like as a PNG.

Shit's so cash

It’s really simple in this incarnation: every black pixel gets turned into a solid tile, white ones get a starry backdrop. In the full version, now destined to never be written, each different color would correspond to a different tile in the tile set. Sadly, I kind of knew before I started writing this system that it wasn’t going to be sufficient for the game I want to write — but sometimes you have to ignore little doubts and bull ahead. The main problem is that I need to attach various bits of metadata to map tiles, like “you can destroy this tile using your gun” or “this is actually in the foreground” or “this tile turns into an enemy when you walk within 4 tiles of it.” Of course, I contemplated going full retard and seeing this technique through to the bitter end despite its obvious drawbacks. Here are some of the workarounds I considered, along with my reaction to considering them:

  • Cram a bunch of metadata into the alpha channel of each pixel. Only 8 bits of info there, and it’s basically impossible to see while editing, but this is my best idea…
  • Choose a different color for every permutation of tile type and metadata. I can’t decide if that’s stupider than using the alpha channel or not
  • Make each map consist of several PNG layer files. This is going to be impossible to coordinate without writing my own level editor, which kind of defeats the purpose of using PNG
  • Put metadata into a separate data file naming each tile by its coordinates. Same objection as above, but also shoot me in the face

Then I discovered Tiled Map Editor, which does everything I want except let me draw arbitrary shapes with paint-like tools. Specifically, it supports arbitrarily many layers of tiles, with the ability to add additional non-tiled objects on top of them. It even has a variety of XNA integration libraries; I chose the one that seems to be the most straightforward and stable, written by Kevin Gadd.

I hope to finish integrating with the Tiled map format tomorrow, but since I’m leaving town for the weekend relatively early it might bleed over into Monday.

Leave a Reply

Your email address will not be published. Required fields are marked *