Saturday, March 29, 2008

Remaking Old Games

The past couple of months I have been working on a secret project. I don't want to say much yet, but what I can say is that it is a remake of my favorite computer game ever.

Why Remakes?


Working on this project made me think about the process of remaking an old computer game. To remake an old game is a relatively easy way to make a fun game, because you only have to solve what I'd like to call "local problems". With a local problem I mean a problem whose solution does not affect any other problem. That is, local problems can be solved one by one without worrying about the big picture. Designing a whole new game on the other hand, is a global problem, since many decisions you make in the beginning will have a huge influence on what your game will look like in the end. I think a large project has a much bigger chance of completion when it is clear at all times what needs to be done next, especially when working with a team.

Besides this, most of the technical restrictions the original developers struggled with are gone, allowing for easy improvements in many different areas. For example, back in the early eighties developers were very limited as to what kind of music could be played from a home computer, not in the least because of memory restrictions. Yet by restricting to the essence of the songs the composers had in mind, they still managed to create very catchy game music. And this music is just screaming to be accompanied by that deep base line that would never have been heard through those PC-speakers, a call for creativity through restriction. This is similar for graphics and sound effects.

A third great thing about remaking an old game is that your game automatically has an audience. Many people will like to play the game for reasons of nostalgia. And this is what makes it a lot of fun to remake it as well!

In short, it is relatively easy to complete a remake and many people will be interested in playing it.

Recreating Tile Maps


When I was working on my project there was one area in particular that consumed a lot of time: assembling building pieces (tiles) into tile maps. It is not that I really mind doing it, normally I would be laying a large puzzle in the Christmas holiday, and this year I decided that I would instead reassemble forty tile maps. However, when I had completed about two thirds, I discovered losslessly compressed images of these tile maps that were created directly from the game (as it turns out, for most old computer games such map images are floating around on the internet, often created from screen shots by obsessed gamers ;) ). Only then I decided that I would write a tool that would automatically assemble the pieces into a tile map file.


An example of a losslessly compressed tile map image.


I had chosen to make my maps in the Tile Map XML-format, a format that is used in Tiled, a tile editor written by my friend Bjørn Lindeijer and Adam Turk. From this open format, it should be easy to export it to any other tile map file. However, the hardest part would not be to assemble the tiles in a Tile Map XML-file, but to find a way to arrange the unique tiles in a way that a human could work with it. After all, at some point these tiles will need to be redrawn, and then it would be convenient if they are arranged in a coherent way. Together with Bjørn, I created a heuristic that uses how often tiles are found to be adjacent in the image of the tile map.


An example of a unique tile image.


The Python program Image2Map.py uses this heuristic to create an image of the unique tiles. There is a separate program MapWriter.py that uses this image and the original tile map image to create a Tile Map XML-file. The heuristic does a quite decent job for the information that can be extracted from a tile map image. We realized that it would be impossible to come up with an algorithm that would create a unique tile image just like a human does, because we humans recognize the objects in the tile map image, while the computer only recognizes the relationship between the tiles. We therefore split the functionality up into these two command line programs to give the user the opportunity to adjust the unique tile image before creating a Tile Map XML-file.

Example Usage


The above picture was created from the tile map image JansHouse.png by typing python Image2Map 8 8 JansHouse.png. Here the argument 8 8 corresponds to the 8 x 8-tile size. After this, a Tile Map XML-file can be created by typing python MapWriter.py 8 8 JansHouse.png JansHouse-Tileset.png. Of course, you need to have Python installed for this to work at all, and you additionally need the python-networkx package (in Ubuntu/Debian, type sudo apt-get install python-networkx).

If you have Sun Java Webstart installed, the resulting file JansHouse.tmx can then be opened by going to Tiled's Website and clicking on "Start Now!". Alternatively, if you have a Java Virtual Machine installed, downloading Tiled 0.6.1 and running it with java -jar tiled.jar should do the job.

Labels: ,