Hi folks,
I'm very confused about an aspect of the collision detection algorithm used in Day 50 and some episodes prior. My confusion is not so much regarding linear blending as a concept, but more on the particular implementation of that blend in the TestWallfunction.
It seems like there are three quantities at play here:
WallX: the X component of the wall we're testing, relative to the center of the test tile
RelX/Y: the distance to the player's current position, relative to the center of the test tile
PlayerDeltaX/Y: the computed end position of the player, relative to the player's current position
What confuses the hell outta me is that the end of the above lines differ in that final remark, i.e. WallX and RelX/Y are relative to center of the test tile TestTileP, but the 3rd is relative to the player's starting position Entity->P.
This kinda stumps my intuition somewhat - don't all of these quantities need to "agree" on a common 0,0 origin in order for the math to work? I don't understand how linearly blending between RelX/Y and PlayerDeltaX/Y up to point WallX gives us the correct result, given the above. What am I missing here?
Any help would be massively appreciated!
Thanks,
- Jonny