Tiles
Continuing from the big entity change from yesterday there is a lot to fix. With the first thing being how to solve the tiles issue. Since the whole tile chunk is basically recreated at the end of every frame. We allocate a lot of memory and not reusing any. And also the tile data is getting lost in the process. But I thought, why just not keep the tile data around and only remove the entity blocks. The entities are the things that need to be unpacked and packed again. So that is exactly how it currently works.

Positions
However it brought me to a different issue. I think the chunk positions are wrong now. They used to be based on the tile instead of the whole chunk. So you would have a round number, which represents which tile you are standing on. Then the offset would determine the fractal number inside that tile. However I think these chunk positions should now be relative to the whole chunk. Like their name basically suggests.

However this change is not complete yet. I have to patch all the places where the position are getting set. As currently everything is put in the origin of the simulation region. And there may be other things broken after this, like grabbing the tile info out. Especially from underneath the player. Though that part of the code needs some work anyway. I think it will be a positive change though once everything is working again. At least the editor code didn’t completely break 🙂

UPDATE:
On my way back home I worked some more on this. I am getting confused though if the tile map position is really wrong or not. The tilemap is also not rendering correctly. When the camera moves, the new tiles that should have come in view aren’t rendered. Instead the initial tiles in view are rendered. As well as collision not working. It’s a bit of a mess now… I’m just not sure where to start looking actually.

Last modified: June 8, 2023