The game I'm building allows users to create their own tile maps essentially, so I want the server to respond with tilemap coordinates if / when a user enters their custom world.
my main issue is storing the data for complex tilemaps.
You can think of tilemaps as arrays. So, you can just use an 2D array of numbers, where each number on the array represent a kind of tile.
If you want to serialize an array, for local storage or for network transmission, you can start by placing the dimensions (unless these are standard), followed by the value of each tile, in binary format, going row by row.
To deserialize, given that you know the dimensions, you can break the stream of tile values into rows. Knowing the number of columns tells you where it should end.
A couple notable alternatives to this approach are:
Now, if your tilemap is sparse, or if it is too large. There might be value in breaking it into chunks, and having a larger structure.
Some solutions: - An array of chunks. Very easy to query. - A quadtree of chunks. Will use less memory for sparse tilemaps. - Just a list of chunks with their coordinates. Easier to transmit.
Speaking of ease of transmit. You might want to have the game request chunks on demand based on the coordinates of the player. And those chunks can be png files. Well, how easy that is depends on your server technology.
If you also need to place other kinds of objects on the map, you may add them to same structure.
As you probably has seen in the documentation, you can use
set_cell to write to tilempas in runtime. See How do I programatically lay tiles with the Godot engine?.