Beep8 logo

Random Numbers Documentation

Random Numbers Documentation Source Code

Random Methods

beep8.Random.int(min, max)

Returns a random integer in the given closed interval.

Parameters

  • min (number): The minimum value (inclusive).
  • max (number): The maximum value (inclusive).

Returns

  • (number): A random integer between min and max.

beep8.Random.num()

Returns a random number between 0 and 1.

Returns

  • (number): A random number between 0 and 1.

beep8.Random.pick(array)

Returns a randomly picked element of the given array.

Parameters

  • array (Array): The array to pick from.

Returns

  • (any): A randomly picked element of the array, or null if the array is empty.

beep8.Random.range(min, max)

Returns a random number (float) in the given closed interval.

Parameters

  • min (number): The minimum value (inclusive).
  • max (number): The maximum value (inclusive).

Returns

  • (number): A random number between min and max.

beep8.Random.setSeed(seed)

Sets the seed for the random number generator. If the seed is null, the random number generator will reset to use the current time.

Parameters

  • seed (*number string*): The seed to use for the random number generator.

beep8.Random.shuffleArray(array)

Shuffles an array, randomly reordering the elements. Does not modify the original array. Returns the shuffled array.

Parameters

  • array (Array): The array to shuffle.

Returns

  • (Array): The shuffled array.

More Beep8 Docs

Actors Documentation

Async Documentation

Core Functions

Input Documentation

App Intro Documentation

Joystick Documentation

Menu Documentation

Music Documentation

Passcodes Documentation

Public API

Random Numbers Documentation

SFX Documentation

Tilemap Documentation

Utilities Documentation