Version: 2.0.0-alpha.8

(PRO) Platformer 1

In this tutorial, we will use this tileset by @KenneyNL to create basic platformer levels. Be sure to check their work out if you like the tileset. We will not care about room decorations very much - the goal of this tutorial is to demonstrate all the basic steps needed to create platformer levels.

result
Example result
result
Example result

Note: I recommend reading Example 1 first as this is a little bit harder to setup and I will not repeat the basics here.

Limitations#

If this is your first time reading about procedural platformers, please see the Limitations section of the Platformer generator page.

Room templates#

Below you can see a few of the room templates that were created for this example.

result
Start
result
Goal
result
Basic room
result
Basic room
result
Basic room
result
Basic room

Doors and corridors#

Even though there are no real corridors used in generated levels, we use the corridor feature to make sure that neighbouring rooms do not share walls.

result
Horizontal corridor
result
Vertical corridor

Moreover, there is a small problem with doors because there are no background tiles inside room templates. And that means that when the corridor rooms are placed over non-corridor rooms, all the walls remain there and it is not possible to go from one room to another (as can be seen in the image below). We usually do not have this problem because when there are background tiles, they are placed over walls and everything is working.

There are no holes between individual rooms because we have no background tile in room templates.

The solution is quite simple. We have to create a simple post-processing task that goes through all door positions and deletes all the door tiles.

[CreateAssetMenu(menuName = "Edgar/Examples/Platformer 1/Post process", fileName = "Platformer1PostProcess")]
public class Platformer1PostProcess : DungeonGeneratorPostProcessBase
{
public override void Run(GeneratedLevel level, LevelDescription levelDescription)
{
RemoveWallsFromDoors(level);
}
private void RemoveWallsFromDoors(GeneratedLevel level)
{
// Get the tilemap that we want to delete tiles from
var walls = level.GetSharedTilemaps().Single(x => x.name == "Walls");
// Go through individual rooms
foreach (var roomInstance in level.GetRoomInstances())
{
// Go through individual doors
foreach (var doorInstance in roomInstance.Doors)
{
// Remove all the wall tiles from door positions
foreach (var point in doorInstance.DoorLine.GetPoints())
{
walls.SetTile(point + roomInstance.Position, null);
}
}
}
}
}

Note: The term doors is used throughout the text but in this context it simply means a connection between two rooms.

Level graph#

Level graph

Results#

result
Example result
result
Example result