diff --git a/src/Math/MathHelper.cs b/src/Math/MathHelper.cs index f53876c6..d3ffb5a9 100644 --- a/src/Math/MathHelper.cs +++ b/src/Math/MathHelper.cs @@ -360,6 +360,19 @@ namespace MoonWorks.Math System.Math.Max(start - change, end); } + /// + /// Step from start towards end by change. + /// + /// Start value. + /// End value. + /// Change value. + public static int Approach(int start, int end, int change) + { + return start < end ? + System.Math.Min(start + change, end) : + System.Math.Max(start - change, end); + } + #endregion #region Internal Static Methods