What is the best way to create easily modifiable levels. I don't want it to be in code, they should be sperate files. Is XML or text better. And if the levels are in order then suppose i have a variable called nextLevel which represents the next level then should it just have the name of the level file or a nice, pre made level object
Eg. if your game was a tile-based platformer, a simple text file would probably be a good choice, using different characters to specify different game objects, '*' could be monster A, '$' could be reward X, etc.
As for choosing next level, one approach might be to just name the level files so they have a natural order ('level001.txt', 'level002.txt',...). That way you can just iterate over the directory containing your level files.
hi, from previous experience I can assure you that an XML file is an excellent way of "storing" levels. The way I did it was to have an LevelManager class that is responsible of loading/saving(for the level editor) and provide the next level. So basicaly the class looks like this:
LevelManager + init() + Level nextLevel() - List levels
So this class is instantiated by your game object. When the game calls init, the class LevelManager will do some preliminary stuff. For example it can read an xml file containing the list of levels files and the order, the levels size, ... . Then the game will start and will need a level so the Game calls levelManager.nextLevel(). So the responsability of nextLevel() is to fetch the right file and construct the level on the fly( you probably want to cache it if you go back and forth(such as Mario 1 where loop forever) and when the level object is done it returns it. Then in your game you have the level Object that you can do anything with(such as rendering it! doh!).
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com