rand(valueA, valueB) → numberengineMath.js:493Returns a random value between the two values passed in
valueAnumber optional, default 1valueBnumber optional, default 0
Random global functions
rand(valueA, valueB) → numberengineMath.js:493Returns a random value between the two values passed in
valueA number optional, default 1valueB number optional, default 0randBool(chance) → booleanengineMath.js:507Randomly returns true or false given the chance of true passed in
chance number optional, default 0.5randColor(colorA, colorB, linear) → ColorengineMath.js:587Returns a random color between the two passed in colors, combine components if linear
randInCircle(radius, minRadius) → Vector2engineMath.js:525Returns a random Vector2 within a circular shape
radius number optional, default 1minRadius number optional, default 0randInt(valueA, valueB) → numberengineMath.js:501Returns a floored random value between the two values passed in The upper bound is exclusive. (If 2 is passed in, result will be 0 or 1)
valueA numbervalueB number optional, default 0randPick(items) → T|undefinedengineMath.js:541Returns a random element of an array or a Set, each as likely, undefined when it is empty
items Array<T>|Set<T>const enemy = randPick(['slime', 'bat', 'ghost']);randSign() → numberengineMath.js:512Randomly returns either -1 or 1
randVec2(length) → Vector2engineMath.js:518Returns a random Vector2 with the passed in length
length number optional, default 1randWeighted(items, weights) → T|undefinedengineMath.js:552Returns a random element of an array or a Set, each picked in proportion to its weight, undefined when none has any weight
items Array<T>|Set<T>weights Array<number>One for each item in order, 0 or more, 0 never picked
const drop = randWeighted(['coin', 'heart', 'gem'], [10, 3, 1]); // a gem 1 time in 14