Cleanup
Decided to cleanup the collision code a bit.
Since I realised that I am doing the rotation stuff wrong.
I check per tile if we can use the rotated entity.
So tile 0 might check with a rotated collision box and tile 1 might check without the entity being rotated.
That’s just weird and I need to check at the end if the entity can be rotated or not.
For now I will implement it in the simplest way possible by just running the collision code twice. But therefore I am compressing the code a bit and creating functions of the code I want to reuse. Couldn’t finish it in time during the morning train ride, so I may try to finish it on my way back home 🙂
UPDATE:
Well, I think I finally did it.
After changing the code around it was pretty easy to do what I had in mind.
Though then I realised that I have to check the collision three times.
Which is definitely not ideal.
First I check if the entity can rotate in its place. If that is possible I check if it also can move when rotated. So that second check won’t run when the entity can not be rotated already. Finally I check the normal collision, so its current rotation and movement. Which we know already works very well.
There is a lot of optimization that can happen in the code. It’s also a big mess really. Though right now, I do not want to touch it anymore. Seeing it work so well is good enough for me right now. I want to finally move on to other stuff. I’m a bit afraid that the collision will break again. But what I tested so far it seemed pretty solid. Didn’t get stuck or anything. So good enough for now, we’ll see how robust it actually is over time.