Create a room

This section will describe all the tools and the process to create a new Scene from scratch.


Recommended tools

- Tiled Map Editor: https://www.mapeditor.org
- Tiled Map Optimizer: https://www.reldens.com/tile-map-optimizer
- Tile Map Generator: https://www.reldens.com/documentation/tile-map-generator > https://github.com/damian-pastorini/tile-map-generator/
- Frame Extruder: https://github.com/lgibson02/FrameExtruder


Create the map

Open the Tiled Map Editor app and create a new map with a fixed size (for example, 30 x 30).

The most IMPORTANT considerations here are:

- "How you split the map layers": since this will affect if the layers go over or below the player sprint.
- "The map layers name conventions": this way Reldens will identify which layers are used for the collisions, the scene change-points, the return points, the respawn areas, and every other map behavior like how the layers will be displayed according to the player. For last, the layer name conventions are used for both server and client sides.

Layer name conventions:

"collisions"

Any layer with this keyword in the name will be used to create blocks used for collisions on the server side. A collision on the server side will be represented by an empty box with the size of a tile, so if you edit your map and hit/collide with an empty space, is probably because you have a tile with a value different from zero in that position in a layer with the word "collisions" on the name.

To avoid this kind of issues, I recommend you to use the TiledMap option to "Highlight Current Layer" (available pressing H while editing the map), this way you will easily see if there's any non-empty blocks in any "collision" layer.

"over-player"

Any layer with this keyword in the name will get an incremental depth on the client side, this way the map view will be affected by the layers order in the file and by the layers name that will get the incremental depth, so even when you can see the layers properly displayed in the TiledMap editor, you may not get the exact same result after we process the layers to all these over the player.

For example, if you have 5 layers, and the 3rd and 5th in the list have "over-player" in the name, the layers will get the following depth in Phaser: L1 = depth 0, L2 = depth 0, L3 = depth 1, L4 = depth 0, L5 = depth 2 > where the player sprite will have depth 0 and go over all the other layers, the L3 and 5 will be over the player.

The layer deep will be calculated like: layer index * map.height * map.tileHeight.

"change-points"

Any layer with this in the name should only have tiles are going to be used as change-points on the server side.

At this time, if you use multiple images to create your maps, you will need to merge them in one, for that you can check the optimized steps below.

"respawn-area"

The layers contain this keyword in the name, the layer will be used for the related respawn object areas, and every tile different from 0 in this layer will be used for respawn objects.

Note: when creating these respawn areas, you don't need to worry about the "non-walkable" tiles since Reldens will filter those when the respawn area is created, meaning you could set a fully occupied layer as your tile map base and still get objects only respawning in the "free" tiles.

"below-player"

Layers with this keyword are rendered below the player sprite.


Create the room in the admin panel

Once the map is exported as JSON, create the room that uses it:

  1. Log in to the administration panel at /reldens-admin (the path can be changed with the RELDENS_ADMIN_ROUTE_PATH environment variable).
  2. Open Rooms > Rooms (/reldens-admin/rooms) and click Create New.
  3. Fill the Name (unique room key, for example reldens-forest-level-1) and the Title shown to the players.
  4. In Map Filename choose the map JSON file exported from Tiled.
  5. In Scene Images choose every tileset image used by the map, see Room Images and Tileset Override.
  6. Leave Room Class Key and Server Url empty unless you use a custom room class or another game server, and use CustomData only for the per room options (JSON).
  7. Click Save. Click any cell of the room in the list to open its view, where Set default makes it the room for the new players, Link rooms creates the change points and return points between two rooms by picking the tiles on the maps, and Room starting point sets the default return point.
  8. Restart the server: the rooms and the maps are loaded when the server starts.
Admin Panel - Rooms list with the Create New button Admin Panel - Create room form with the name, title, map filename and scene images fields

Add multiple tilesets to the same map

A map can use more than one tileset: edit the room and select all the tileset images at once in Scene Images. Each uploaded file name must be the image of a tileset in the map JSON, the game loads each image with its file name and adds it to the tileset that uses it:

// ...
"tilesets": [
    {
        "columns":14,
        "firstgid":1,
        "image":"reldens-forest.png",
        "imageheight":408,
        "imagewidth":476,
        "margin":1,
        "name":"reldens-forest",
        "spacing":2,
        "tilecount":168,
        "tileheight":32
    }
// ...

When the room is saved, the Scene Images are replaced with exactly the images the map tilesets use, and those images show the alert icon and can not be removed while they are in the map:

Admin Panel - Edit room form with the scene images of the map tilesets

See Room Images and Tileset Override for the details and how to manage the images by hand.


Manually create new change points

The change points are saved only in the storage (for now), and to create them, you need to know the tile-index where it was specified in the map file.

How to get the index?

If you are using Tiled it will give to you the tile coordinates let's say "39,19" (x,y) in a "48x28" tile map like below:

Reldens - Tiled Map Editor, tile column and row

39,19 is the door on the blue house, with that information you can do the calculation:

tileIndex = y * mapW + x > 19 * 48 + 39

And you will get the index = 951, which is the required value for our change-point.

In the administration panel, go to the Rooms / Change Points section:

Reldens - Administration panel, change points list section

Click on "Create New" button and complete the form with the origin room, the tile index you just calculated and the destination room:

Reldens - Administration panel, create change point

Instead of typing the Tile Index, you can also click Pick in map and click the tile on the room map.

Click on "Save" and you are done. When the player hits that point, it will be automatically sent to the next room.

The tile must be walkable: a tile marked by a layer whose name contains collisions is refused when the room is created. The Link rooms option of the room view creates the change point and the return point in one step.


Manually create new return point

What is a return point?

Basically, these are the room position where the player will be located when entering into the room.

If a room has a single entry point, then you will have a single and "default" return point. However, when a room has more than one entry point, then you will need to specify to which room the return point depends on.

Let's say we have a town with two houses:
- "Default example": you are in the town > go to the house #1 > this one only has one return point (the default one), since you are always coming from a single door in the town.
- "Depend on previous room example": when you move out from the house 1, you will need to specified at which point of the town the player is going to be located, so there you will need two return positions for the town, the default that will be always the house #1, and the dependent one will be for the house #2.

To create a return point, you need to specify:
- The "Room ID" is where the player will be entering after the room change (the destination room of the change point). If you go from the town into the "house #1" this Room ID will be the room_id of the house #1.
- The "direction", is how the player will be displayed (looking up, down, left or right).
- The "x" and "y" values are the coordinates in units, where the player will be displayed in the map (here will be the position in the house #1). To calculate the coordinates, you need to multiply the tile column and the row by the tile size.
- If it's the "default" position for that scene or not.
- The "From room ID" is from where the player is coming, in this cae the town room ID.

Go to the admin, to the Rooms / Return Points section:

Reldens - Administration panel, return points list section

Click on "Create New" button and complete the form with the required information:

Reldens - Administration panel, create return point

Click on "Save" to create the new return point.

Restart the server so the new change points and return points are loaded.

Go Up