-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Closed
Description
Version
- Phaser Version: 3.50.1
- Operating system: Windows 8.1
- Browser: Chrome
Description
The built-in weightedRandomize method of the TilemapLayer does not produce consistent layer distribution between refreshes.
This makes impossible to use this method and produce a consistent output from a given seed.
I've put the seed param in the game config and I've also inspected the phaser source code at https://github.com/photonstorm/phaser/blob/v3.50.1/src/tilemaps/components/WeightedRandomize.js and I've confirmed that the standard Math.random is used instead of the Phaser.Math.RNG functions. I'm not sure how to import it or I've had opened a pull request myself.
Example Test Code
const map = this.make.tilemap({
tileWidth: 64,
tileHeight: 64,
width: 30,
height: 30
});
const tileset = map.addTilesetImage("terrain-tiles", null, 64, 64, 0, 0);
const layer = map.createBlankLayer("Terrain", tileset);
layer.weightedRandomize(0, 0, 30, 30, [
{ index: 0, weight: 55 },
{ index: 20, weight: 45 }
]);