This is a tycoon game using isometric view and coordinates
I've been brainstorming ideas about the best way to assign custom data to specific tiles in an atlas texture. (ie: assign a value to a grass tile allowing me to define it as terrain in a script, assign a bool to define the block as solid or not, etc.)
The big challenge here is I'd much prefer not hard coding these properties so that I can add new tileset assets without changing code. I'll still go the hard coding route if it turns out to beat all the other methods but I still thought it was an interesting subject especially as I've barely found any example or information about how game devs usually store data of tiles that are part of a AtlasTexture/tileset
Here's my take on it: storing the data as pixels in the spritesheet (I'll post a picture of my spritesheet template below)
This spritesheet is for 128x128 tiles but the game can handle different sizes.
This way I just need to edit the spritesheet and I can put it in my game, the scripts will handle the logic and organize the data.
When a tile is placed, it's data will be stored in a dictionary with the tile's position as it's key
This is very useful in the early development stage as we frequently reorder, change and add tilesets.
issue #1: What equation do I need to get the tile size of tiles that aren't squares?
if the tiles are squares, I just need to divide the height of the texture by 2 to get the tile size, but this logics break for tiles that aren't squares.
I feel like there should be an equation that solves that but I haven't gotten my finger on it yet.
I could also store that value as pixels but an equation would be best.
issue #2: encoding strings with bits is tedious and It may complexify traducing the game in another language.
issue #3: This technique may overall take more time to implement than to hard code each tiles.
I've never seen any tilesets like mines in a game before. Am I totally crazy to do that ? Am I missing another option that is superior to the other ones above ?
I won't list all the pros and cons of my method but comparing it to hard coding I found that so far, they kinda balance each other out.
I'm opening a discussion on this subject because I probably missed big pros and cons of each method and may be oblivious to other methods.
What do y'all think ?