diff --git a/src/flixel/math/FlxMath.hx b/src/flixel/math/FlxMath.hx index 339536a..a790a06 100644 --- a/src/flixel/math/FlxMath.hx +++ b/src/flixel/math/FlxMath.hx @@ -1,7 +1,40 @@ package flixel.math; +import raylib.RayMath; class FlxMath { + /** + * Minimum value of a floating point number. + */ + public static inline var MIN_VALUE_FLOAT:Float = 5e-324; + + /** + * Maximum value of a floating point number. + */ + public static inline var MAX_VALUE_FLOAT:Float = 1.79e+308; + + /** + * Minimum value of an integer. + */ + public static inline var MIN_VALUE_INT:Int = -MAX_VALUE_INT; + + /** + * Maximum value of an integer. + */ + public static inline var MAX_VALUE_INT:Int = 0x7FFFFFFF; + + /** + * Approximation of `Math.sqrt(2)`. + */ + public static inline var SQUARE_ROOT_OF_TWO:Float = 1.41421356237; + + + /** + * Round a decimal number to have reduced precision (less decimal numbers). + * @param value The number to round + * @param precision The number of decimal numbers. + * @return The rounded number to the specified precision + */ public static function roundDecimal(value:Float, precision:Int):Float { var mult:Float = 1; for (i in 0...precision) { @@ -9,4 +42,8 @@ class FlxMath { } return Math.fround(value * mult) / mult; } + + public static inline function lerp(start:Float, end:Float, amount:Float):Float { + return RayMath.lerp(start, end, amount); + } } diff --git a/test/src/PlayState.hx b/test/src/PlayState.hx index 457c517..581f045 100644 --- a/test/src/PlayState.hx +++ b/test/src/PlayState.hx @@ -1,5 +1,6 @@ package; +import flixel.math.FlxMath; import flixel.FlxG; import flixel.FlxState; import flixel.FlxSprite; @@ -30,8 +31,8 @@ class PlayState extends FlxState { override public function update(elapsed:Float) { super.update(elapsed); - scythe.x = RayMath.lerp(scythe.x, Raylib.getMousePosition().x, elapsed * 10); - scythe.y = RayMath.lerp(scythe.y, Raylib.getMousePosition().y, elapsed * 10); + scythe.x = FlxMath.lerp(scythe.x, Raylib.getMousePosition().x, elapsed * 10); + scythe.y = FlxMath.lerp(scythe.y, Raylib.getMousePosition().y, elapsed * 10); if (Raylib.isKeyPressed(KEY_SPACE)) { FlxG.switchState(new OtherState());