PCG Random Number Generator for Defold

PCG Random Number Generator Native Extension for the Defold Game Engine.

This extension allow you to generate random numbers using minimal C implementation of PCG. It uses entropy seed internally. You can switch to Time based seed by uncommenting lines(Check the source code).

Defold Assets: https://www.defold.com/community/projects/140436/
Github: https://github.com/selimanac/defold-random

Installation

You can use PCG Random in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/selimanac/defold-random/archive/master.zip

Usage

rnd.number()

Returns a 32 bit integer

rnd.range(min, max)

Returns a 32 bit integer between min and max values.
Similar to math.random(1,50)

rnd.double()

Returns a floating point between 0-1
Similar to math.random()

rnd.toss()

Toss a coin. Returns 0 or 1 (0 = ‘H’, 1 = ‘T’)

rnd.roll()

Roll the dice. Returns between 1-6

rnd.check()

Testing entropy.