Level design / architecture

Hard-coded vs separate files

Hard-coded levels are levels that are programmed directly into the source code. These levels are usually represented as classes, structs, or associative arrays/dictionaries. These are more common in simple games like shoot-em ups. The advantages of this are that you don't have to write a function to load the files and you don't have to worry about missing files, but as you make more complex games, writing hard code levels may become tedious.

More complex games store levels in separate files. Some use plain text files, while others use formats like XML, JSON, or binary. Most game engines have specific formats for game levels and maps.


One of the most common ways to make levels is tiling. Tiling involves placing the game objects in a two-dimensional array. This makes it easier to place game objects and gives you a visual representation of where everything is and allows you to create full levels efficiently using a few art assets.

The most common way to do this is have each level stored in a textfile where each line represents a row and each character represents a tile. (e.g '|' represents a wall). The game will then read the textfile and create tiles and objects based on the characters in the file and its position.

Level editors

A level editor is a tool that is used to create and edit levels. Most level editors use tiling and store the levels in text files but give you a better visual representation of where things are located and how they are seen in the actual game. As previously stated, most game engines already have built in level editors and formats that the levels are stored in. If you are not using an engine, there are level editors out there like Tiled, but you still have to write a parser for the levels based on the format that these level editors use or use a third-party parser.

See Also

External links

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License