Lojemiru / Another-Mediocre-2D-Engine

Ran out of name ideas. Not affiliated with AM2R.
MIT License
4 stars 1 forks source link

PlayerPool GetClosest and GetClosestOnSide incorrect behaviour #14

Closed DodoBirby closed 1 year ago

DodoBirby commented 1 year ago

The GetClosest function uses an incorrect algorithm to calculate the closest player. Situation: 2 players at equivalent y coordinates, but 1 player is closer on the x coordinate. Expected result: Player who is closer on x coordinate gets chosen. Actual Result: Arbitrary based on which player is first in the pool.

GetClosestOnSide seems to not take into account y coordinates for left and right sides, and doesn't take into account x coordinates for up and down sides but depending on their intended use case this might not be a bug.

Lojemiru commented 1 year ago

Definitely unintended behavior. Reviewing the methods, the code I wrote for these is exceptionally dumb... should be fixed now, pushing shortly. Thanks for the report!