How to store tilemap data?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thewraithmod
:warning: Old Version Published before Godot 3 was released.

I would like to make a platformer game in the style of Spelunky.

Spelunky handles level generation by picking random premade “chunks” and placing them in the correct positions.

Example: Spelunky Generator Lessons

In Godot, how would I be able to create these premade level chunks using the tilemap node? Would I need to create separate tilemap scenes or have one scene with a collection of tilemaps that represent these different parts of a level?

I was thinking that I could just have one tilemap that represents the entire level and load in an array with the data of the tilemap chunk I am trying to use.

Also, when I’m generating a level would I just need to instance a new tilemap and place it where it needs to go?

:bust_in_silhouette: Reply From: quijipixel

You can manually set tiles from a TileMap using its API function set_cell. You just need the coordinates in the grid and the tile’s index. If I were to implement this I’ll probably go for the big TileMap with all the rooms, creating scenes as rooms will get me too much room nodes and I feel more comfortable with one TileMap node instead.