Positions
After thinking about it for a day I know what to look for. As well as the positions are somewhat correct. I decided to treat the tile chunks as squares again. Maybe the tile chunks themselves are already doing that. But I know at least the rendering of the tiles is not. And then the positions can be calculated easily and transparently.

Tile Rendering
As for the rendering itself. It was just very badly made. Like I said, it didn’t treat the tile chunks as it should have. There was some hardcoded nonsense in there which determined how many tiles were rendered.

It is now all based on the camera bounds and the simulation region origin. Way better and way more robust as well. The code is also easier to read. Overall just happy with that change. But I’m not out of the woods yet. The entity position, in this case the position of the player, is not set correctly. This is probably just a result of the packing and unpacking. However it also breaks the tile rendering, while the entities themselves seem to render perfectly fine. And I think I just came up with a solution, as I was typing this haha. So that is something for my train ride back home 🙂

UPDATE:
I think I managed to fix the entity position problems. However now the tiles aren’t rendering properly anymore… And besides that the collision with the tilemap is also not working. However that was the case since Monday.

The problem was in the conversion function. It was still using the size of a tile instead of a chunk. So it was an easy fix and one I anticipated. But I just wasn’t understanding the whole situation clearly. Until I used some known variables and then I found it quickly. Something I definitely learned to do more and more quickly as well from Handmade Hero.

Last modified: June 8, 2023