After trying to work with the code I still had I had enough… I’m saving the old code and starting over. First visualizing the tile region that we should check. Then bit by bit building it back up. First with a very simple collision model, probably AABB. After that we slowly build it to SAT again with proper collision resolution.
So how did that go? At first I thought it went well. Having some nice visuals which seemed to work. Clearly showing the current position and the position after that frame if there is no collision. However, the tiles that are checked seem to be a tiny bit off. So I was trying to investigate that until the train couldn’t go further.
On my way back home I could continue. Slowly but surely it became clear that actually the tiles being checked are not the correct ones. Why? Well I don’t know and it’s driving me a bit crazy. I just take the current position and the velocity. Creating two rectangles out of these which seem to be correct. After that it goes wrong. As the rendering of the tiles seem to be perfectly fine.
Points that I render appear on the right tiles. I can check this as the color of the points indicate the tile ID. So if the tile is one the player should not be able to get to it will be red. However, the are just not the right tiles getting lit up. The region of tiles is also square, while I at least expect some rectangular shapes more often. I am just done with it for today and had to write this devlog still. Really drives me crazy how such simple things don’t work somehow. I guess I am just very stupid when it comes to these things.