Setting up the level generator scene

We are ready to start working on the level generator’s scene itself.

Create a new 2D scene and rename the root node to RandomWalker. Save it as RandomWalker.tscn.

Add the following nodes:

  1. A Camera2D, to center the view over the level. Don’t forget to turn on Current in the Inspector otherwise the camera won’t be active.
  2. A Timer that we are going to use to slow down and visualize the algorithm, that otherwise generates levels in a split second.
  3. A TileMap, to draw the level. Assign tileset-prototype.tres to Tile Set in the Inspector.

Rename the TileMap node to Level. Like before, make sure to also alter the x and y values of the Cell > Size to 60 pixels to match our assets.

Select the Timer node and, in the Inspector, toggle on its Autostart property. That way, we don’t have to start the timer from the code manually. You can change the Wait Time property to control the time interval between each step in the map-generation process. Using a timer gives us a rudimentary tool for debugging. It also adds a build-up animation effect to showcase our algorithm.

Now, we are ready to code the RandomWalker, which we are going to do in the next lesson.