minigdx / tiny

Tiny is a lightweight 2D game engine that allows developers to easily create games using the Lua programming language.
https://minigdx.github.io/tiny/
MIT License
121 stars 6 forks source link

Fix for broken behaviour in math.clamp #4

Closed TomFromThePool closed 1 year ago

TomFromThePool commented 1 year ago

There is an issue in the implementation of math.clamp, which means the value to be clamped is returned rather than the result of the check against the lower bound in all cases where b > max(a, value)

This commit fixes that behaviour, ensuring that the correct value is returned in the case of b > max(a, value)

Additionally, this commit defines the expected behaviour when a > b.

Tests included.

dwursteisen commented 1 year ago

Hello 👋

thanks you for your proposal! I’ll merge your fix 🙂

regards.