Tile Map Generator
This tool was designed to help users to easily create tons of random tile maps for their games.
In order to use this, you will need to create a small script to provide the data and then run it through NodeJS.
You can find the tool on GitHub or just install it through NPM:
GitHub: https://github.com/damian-pastorini/tile-map-generator/
NPM: https://www.npmjs.com/package/@reldens/tile-map-generator
Once you install it, you can use the tool in two ways:
Generating files for each element to be passed to the map generator:
https://github.com/damian-pastorini/tile-map-generator/tree/master/examples/layer-elements-object
Generating a single file with all the contents and setting everything on the tile map:
https://github.com/damian-pastorini/tile-map-generator/tree/master/examples/layer-elements-composite
Note: make sure to have a "generated" folder created previously to start generating the maps (I will fix this in the following versions).
First let's have a summary on how the generator itself works:
You need to provide the map data, most of these fields are the same provided in any Tiled-Map JSON file under the "tileset" property, but some with small changes:
And some new:
When the process starts the map size will be calculated based on the area for the total elements to be placed + the specified free space, for example:
element 1: 2x2 tiles, quantity 2
element 2: 3x3 tiles, quantity 1
freeSpaceTilesQuantity = 2
The map will get the size putting the first 2 elements in the same row, the next element in the second row, and then will add the free space, this will give us:
4 tiles width for the elements on the first row by 2 tiles height > map size 4x2
for the next row it already has space enough for the 3 tiles width, so it will only add 3 tiles more to the height > updated map size 4x5
then add the free space of 2 tiles > updated map size 6x7
The elements will be placed randomly without colliding each other.
After calculate the map size and placed the elements, it will search for each element with a path layer and the single tile marked with the "pathTile".
With this information it will generate paths from the main path starting point (randomly placed in the map borders using the mainPathSize), to each element pathTile.
In order to get the layer elements we need to create the contents by following some conventions and setting the configurations required for the randomize process (like how many of each element, paths, ground variations, etc.).
Let's open Tiled (https://www.mapeditor.org/), and check how a normal map for Reldens looks like (see the image above is from the default sample theme).
As you can see, the layers naming is following the conventions, in summary:
"collisions" is used for everything that will collide with the player or enemies.
"over-player" is used to make the entire layer always be displayed over the player.
"change-points" is used to define where the room will send the player to another room.
"respawn-area" is used to define where specific objects will respawn after defeat.
Obviously "collisions" and "over-player" can be combined so you can get the player collide with bodies that could be below the current tile without need to define the same tile twice.
Additionally, for the randomize process you will need an extra convention:
"path" which is used to place the points where the elements will be connected to the paths in the random map (this will get clear later).
With these in mind, we will need some extra conventions for the randomize process, so let's prepare the elements and required scripts.
Last updated