Thursday, July 7, 2011

Managing the levels

I started the level management by thinking a lot about how it should work. I came up with several different ideas. My first idea was to write a custom content importer but I ran into compatibility issues and decided to go a different way. The method I decided upon was directly importing the files into the program directory and loading it in from there.

First thing I did after all that thinking was create a level class and a tile class. The level class contains a grid of tiles, a timer for when we eventually implement the timing mechanism, a starting point and a ending point.

This is the format of the level file. Each character represents a different type of tile and is separated by a blank space. This file is then read in line by line. By using the blank spaces as a separator I split the line up and converted each character into a tile object. Each tile object has an x/y location and a tile id. After that all that is left to do is to draw them on the screen.
 This image shows the level when drawn using temporary tile images.

1 comment: