What is the idiomatic way to store world/map data for a tile game in Godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By captain_mediocre

I’m new to Godot, and I’m porting/remaking a top-down bomberman-style game with a tile map, and I’m wondering what is the recommended way to manage map data in Godot?

My question is for things that need to align with the tile grid, such as bombs.

I’m wondering whether it’s better to use an array the size of the tilemap (width * height) and store information in there every time a bomb is placed or exploded, or whether in Godot it is better to just place the nodes and just use those directly?

To give an example, when I go to place a bomb, I want to check whether there is already a bomb at that location. Having an array makes this easy - you just look up the array and check whether that index in the array is null or 0 (whatever I choose). And when placing a bomb I would store a reference to the node in the array at that index.

This is how I did it in my previous version of the game but is that the idiomatic way to do this in Godot?

:bust_in_silhouette: Reply From: njamster

Your approach sounds fine. If you don’t have an array to keep the node references, you would need another way to check if a position is occupied and if so, by what. While that is possible (you could e.g. name the bomb-nodes after their position, so “09_01” would be a bomb at the 9th tile from the left and the 1st from the top), I wouldn’t call that “idiomatic” - just two solutions for the same problem.