Better seed handling in perlin noise
Add seed, width and height to get param Make map terrain more generic
This commit is contained in:
@ -9,7 +9,7 @@ class PerlinNoise
|
||||
private float $seed;
|
||||
private int $_default_size = 64;
|
||||
|
||||
public function __construct(float $seed = null)
|
||||
public function __construct(?int $seed = null)
|
||||
{
|
||||
//Initialize the permutation array.
|
||||
$this->p = [];
|
||||
@ -36,10 +36,11 @@ class PerlinNoise
|
||||
|
||||
//And set the seed
|
||||
if ($seed === null) {
|
||||
$this->seed = time();
|
||||
} else {
|
||||
$this->seed = $seed;
|
||||
$seed = time();
|
||||
}
|
||||
|
||||
srand($seed);
|
||||
$this->seed = rand(0, 1000000);
|
||||
}
|
||||
|
||||
function noise($x, $y, $z, $size = NULL): float|int
|
||||
|
Reference in New Issue
Block a user