Sunday 9 December 2007

Worlds from text

Today I came upon an incredible way of creating levels quickly in tile-based games. It was taken from the game Super Mario Bros. (a remake of the original Nintendo game), written by someone going by the name of PyMike. Essentially, the levels are entirely tile-based and loaded from text files. For example, it might be programmed to replace an "M" with an image of grass and an "O" with an image of the sun; meaning a nice-looking level with grass and a sun could be created like so:


----------O---
--------------
--------------
--------------
MMMMMMMMMMMMMM


I decided this was almost certainly the bes
t way of making the levels in Slipslide, so I had a go at making a level loader myself. The results are actually quite good. Here's a simple thing I made with it:
Make sure you pick your jaw up off the floor before someone stands on it!
Although it doesn't look like much, this is what's known as a black triangle; it doesn't look impressive but it's proof that a very complicated system is functioning perfectly behind it. This work of art was created from a text file containing 240000 ones and zeroes, with zeroes being replaced with black and ones being replaced with white. Really, they could be replaced with absolutely anything; I just used black and white to save time whilst making the demo.
You may be wanting to know how my collision detection experimenting went; well, following this tutorial I got some stickmen to know when they're colliding with each other. However, when I tried to implement it into the Slipslide movement demo it seemed to be very buggy. I think that the pixel-perfect collision would be too accurate and therefore inaccurate (like in the 3D Slipslide game), so I'm instead going to develop my own tile-based system for perfect accuracy.
Animation was a lot easier than I thought it would be, I just included something in the update method for the sprite that changed the image every time it was called. Of course, these images were preloaded at the start to make it more efficient (it'd have to load an image every single frame otherwise).
Now for more tile-based fiddling...

No comments:

Post a Comment