Page 1 of 1

Use seed to create value in range

PostPosted: Wed 13 Sep 2017, 19:20
by Abzence
Hello all.

I've just started out with Gdevelop and eventually plan on making a platformer similar to Super Mario but with procedurally generated platforms with varying length and distance. (Not endless)

I was thinking of using something similar to the example below to create a pseudo random number using a seed.

Code: Select allMath.seed = 6;
Math.seededRandom = function(max, min) {
    max = max || 1;
    min = min || 0;
    Math.seed = (Math.seed * 9301 + 49297) % 233280;
    var rnd = Math.seed / 233280;
    return min + rnd * (max - min);

Example from here

Once the number is generated I'm wondering how I should go about creating the platforms. These should not be random but generated using the seed so the same seed always create the same level layout.

The platforms should vary in length from 1 block to perhaps 4 blocks.

EDIT: too little sleep that I couldn't really think before.
rng = Math.seededRandom(4,1); Will generate values from 1-4.

I'm planing on making this a native app so using javascript for this might not work?

Any help and pointers in the right direction would be greatly appreciated and I'm sure others can benefit from the help.