Skip to content

Secludedness: Map Format and Custom Maps

In addition to the post on gameplay and design I’d like to explain how the map format is structured and how to build your own maps for Secludedness. In my humble opinion it’s a pragmatic way to create a clean map structure with libgdx and maybe a good example for other projects.

Map Format

Secludedness uses the TMX Map Format and the maps are created with the Tiled Map Editor. In TMX a map consists of several layers, which are either tile based (with tile sets) or a group of objects. Nearly every element could contain custom properties for additional information.

At the moment a map for Secludedness consist of six tile based layers and one object layer. Each layer has a name by which it’s identified in the game. The layers have a specified order (1. = top layer) to make the rendering and map building easier.

  1. player a object layer for player start position and addition player properties
  2. fog a tile layer to hide a field
  3. exit to set level exits with tiles
  4. trap for tiles which reduce the players health
  5. portal for the teleporting tiles
  6. foreground for not accessible tiles
  7. background as a layer for background tiles (just rendering)

The player layer consists of a startpoint object, which contains the property health. The function of a tile is determined by the layer name, so you can use textures from different tile sets. For performance reasons it’s recommended to use only a single tile set per layer. The advantage of this separation is, that you can easily change tiles or tile sets (textures) as long as you place them in the correct layer. There are no obliging textures for a map, so that it’s possible to create custom maps with their own appearance. For map makers this means, that there are no predefined textures for a map. They can add custom textures without any code change.

At the moment the texture of the player character is predefined. It is planned that the player selects the texture of the player character in the settings or it can be set by the map maker in the map format. However this features aren’t implemented yet.

Building your own map

Maps can be easily created with the editor Tiled. Tiled is open source and available for Linux, OS X and Windows. After you’ve started Tiled the creation of a playable map is just some steps away. At first create a new map with a tile size of 64 px and the desired number of tiles.

Create new map in Tiled

Save the map in the maps folder. Then create the above described layer arranged in the correct order. You can add your tile sets in the layer menu and draw the map layers with the included tiles. The texture file and the tile set (tsx file) should be in the textures folder, which is located on the same hierarchy level as the maps folder. Take a look at the github project for the correct structure of the folders and files.

Map view

At last create the object layer player with the object startpoint and the property health. Make sure that health value is reasonable so that the map can be played properly.

Object layer player

Congratulations! You’ve created your first map for Secludedness. Unfortunately it’s necessary to modify the source code to play the map. Open the file and add your map to the list of available maps. In future version of the game it will automatically add all maps from the maps folder.

I hope this post explains the map format and the creation of custom maps sufficient. If you have any questions write a comment, send an e-mail or contact me via Google+ or Github.

Published inDevelopment

Comments are closed.