@writegames.com/game-math
    Preparing search index...

    @writegames.com/game-math

    @writegames.com/game-math

    A library of useful math classes & functions for game development, involving linear algebra, trigonometry, RNG, and more.

    npm version

    # choose based on your package manager
    npm i @writegames.com/game-math
    pnpm add @writegames.com/game-math
    yarn add @writegames.com/game-math
    • Vec2, Vec3, Vec4, Mat2, Mat3, and Mat4 classes
    • Dot products, cross products, vector-matrix multiplication, transformation matrices, and more
    • Random class
      • Uses xorShift32 as default random function
      • float(n) - returns a random float between [0, n) (exclusive)
      • chance(n, max) - returns true or false based off of n in max chances (ex: chance(1, 5) would return true 20% of the time)
      • int(n) - returns a random int between [0, n) (exclusive) (ex: int(3) would return 0, 1, or 2)
      • range(a, b) - returns a random float between [a, b) (exclusive)
      • bool() - returns true or false
      • sign() - returns -1 or 1
      • angle() - returns a random angle in degrees [0, 360)
      • choose(...items) - returns a random item from the items passed (ex: choose(1, 2, 3) would return 1, 2, or 3)
      • shuffle(arr) - shuffles an array using the Fisher–Yates shuffle algorithm
      • vec2(scale) - returns a random Vec2 of the length of scale (defaults to 1)
      • vec3(scale) - returns a random Vec3 of the length of scale (defaults to 1)
    • WIP
    • WIP

    While this is pre-1.0, GameMaker compatibility may be incomplete and/or broken.

    © 2025 WriteGames.com. MIT License