Alphish / gm-community-toolbox

A collection of utility functions for GameMaker.
MIT License
34 stars 6 forks source link

ISS-3/ISS-15: Value-reaching function (approach, approach_angle, lerp_angle) #24

Closed Alphish closed 1 year ago

Alphish commented 1 year ago

Resolving issues #3 and #15.

Implemented the approach, approach_angle and lerp_angle functions, and created test cases for them.

Additionally, created demonstrations comparing lerp/lerp_angle and approach/approach_angle for reaching specific values. The user can also pick different lerp amounts and approach steps as well.

There is also a demonstration of using compounded lerp x approach for using lerp, and then approach to reach the value. This is useful when someone wants to cover both large and small differences in a short time (lerp excels at the former, approach at the latter), reaching a quick stabilisation point (when current value equals to the target). This is especially visible for the number-changing demo, but also can be handy for position changing (e.g. when you move camera to follow the player, and it needs to quickly stabilise to avoid the annoying jitter towards the end).

That said, the "lerp x approach" function doesn't involve any separate function, it just compounds lerp/approach or lerp_angle/approach_angle.

image

Mercerenies commented 1 year ago

I like that we normalize all of the angles when we return values.