Loading Tilemaps
The game won’t be any fun if you can only drive around in a small hardcoded track. So it was time to load the track file from disk and use that in the runtime. There is already code for loading that file on the editor side. Though now I have copied the code to the runtime part of the game.

Currently only the first file that is found can be used. I haven’t decided yet if I should keep the track files separate from all assets and therefore keep it in its own file format. I am gravitating towards that idea, since I think the files can be somewhat large. So combining it with assets, like textures, it could be a bit too much. Though what am I worrying about in the end? The file would be under 10MB I think. Not something a Nintendo Switch or Xbox One can’t handle 😅

The problem with keeping it in a separate file is that there needs to be a new system to find the track you want. I don’t want to load all tracks into memory. Otherwise we could easily just make one asset pack with all tracks and be done with it. Though maybe an asset pack can reference all tracks. Than we look into that table to find the file we need. Or we just create that table at runtime with and somehow put the right tags on the files. I guess I should take a look at the asset system again. I think that one creates a table at the start of the game as well.

On my way back I managed to get the tilemap actually working. As it turned out the data was valid, it was just all dumped into one place. Though some tiles got placed correctly it seemed. It was simply the position of where the chunk should be placed that was incorrect. So in the end it was a quick fix, it just took one train to figure out what was actually happening.

Though after that I found out that there are some tools I forgot about. Like painting on the tilemap and actually placing trees. So those also need to be moved into the runtime section. Then maybe in the end I am able to bundle the code into one nice function that can be compiled out of the game. That it only is included in debug mode.

Last modified: May 25, 2023