Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am planning on making a 2D game, however different from my last personal projects I want this one to have enhanced graphics, with custom-designed levels. My previous 2d platformers were tile-based, in which I made a map editor for to create levels.

However, I am wondering the best way to implement custom designed maps? For say, some grass is a litter higher than others, flowers here and there, cool drawings and structures along the way, etc. instead of just the same old tiles over and over again. I am thinking but I just can't grasp the idea of how to implement it. I have seen it done in other games and am interested to see how they accomplish it, but can't get my hands on some source code. :(

share|improve this question
    
You need to explain more about exactly what it is you're trying to achieve. –  Nicol Bolas Jun 24 '12 at 5:24
    
I want more customization in map creation than just tile-based, how is the best way of doing that? –  Qasim Jun 24 '12 at 5:26
    
That's usually called procedural graphics or procedural content generation. More details can be found here: pcg.wikidot.com –  Eugen Constantin Dinca Jun 24 '12 at 5:29
    
@Qasim: "I want more customization in map creation than just tile-based" That's not really narrowing things down. Be specific in what you're looking for. –  Nicol Bolas Jun 24 '12 at 6:45
    
@Qasim are you looking to implement a level system that has a higher precision than a tile-based system (i.e. pixel-perfect)? Or are you simply looking to make a tile-based system much more detailed? I have answers for both and more, but I am not quite sure what exactly you are asking. Perhaps you can provide examples of other games that use a system similar to what you are looking for? –  DBRalir Jun 24 '12 at 7:09
show 2 more comments

1 Answer

up vote 11 down vote accepted

There are many different types of level systems, most of which are customized specifically for a single game. This answer will not cover every implementation detail of these systems, but rather an abstracted explanation of each.

Tile-based

Although most tile-based systems are very shallow and are incapable of supporting much detail, it is possible to overcome this. At the core, a tile-based system is a two-dimensional array of cells, each filled with a piece of data that details it's contents.

The first action most designers take to add detail to a tile-based system is to add layers. Layers allow you to have multiple grids of cells stacked on top of each other, giving you the opportunity to add things such as shadows and things that are raised vertically off the ground, such as the crown of a tree or a tall lamp post.

Also, most tile-based systems use tile sets. Tile sets are palettes of data that the level system can use to store tile information. This allows you to more efficiently support a higher number of tiles, because if you need more room, you can just add another tile set.

You can add detail to each tile via metadata. For example, you might have only one "grass" tile. Instead of making new tiles for each height of grass, you can simply add metadata that describes this height.

Arbitrary Placement Level

Although a bit more complicated than a tile-based system, an arbitrary placement system gives you free control over the location of objects. Basically, every object in the level is given a position, rotation, and scale. So instead of having a list of cells that contain objects, you now have a list of objects that contain positional data.

Since each object contains it's own set of data, it is possible to store graphical information for each object. For example, instead of using a tile set to store the graphics for each type of tile, each object can now contain unique graphical data, such as the name of an image file.

Because the objects can intersect with each other, you will need to give each tile (along with it's X and Y position) a Z position, which is essentially it's layer. Objects with a higher (or lower, if you choose) Z position are drawn last, so that only the most prominent objects are shown on top, and all background objects are drawn behind these.

Arbitrarily placed objects can also have arbitrary sizes, allowing you to specify a long stretch of grass as one object, instead of have several tiles stored in several cells. Thus, an arbitrary placement system uses less memory than a tile-based system (usually). Also, things other than terrain may be stored in the level data, such as enemy placement, dynamic lights, and events. Although it is possible to make a tile-based system that included these features, it is almost certainly more difficult.

Conclusion

As you can see, both tile-based and arbitrary placement systems have their advantages, so it might be hard to choose between them. However, there is no reason you cannot have both. You can make a tile-based system as the base, and store all of your basic terrain in that, and then you can specify an arbitrary placement system on top of that, for adding objects that cannot be represented in a tile-based system.

In the end, the only way to get more detail into a level system is to force it in. Add more layers and tile attributes to your tile-based systems, and overlay an arbitrary placement system on top of that for the fine details.

share|improve this answer
    
Wow, that was a long answer. Does anybody have any suggestions on how I can cut down on the size? –  DBRalir Jun 24 '12 at 7:59
    
It was an excellent summary of the two types of level systems mentioned, and looks to be at an appropriate length. Thanks for the help. –  Qasim Jun 24 '12 at 13:57
    
No problem. I wish I could give you a more concrete answer, but the subject has more to do with artistic design than actual programming. –  DBRalir Jun 24 '12 at 19:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.