Skip to content

Commit 65ead45

Browse files
committed
Moved RNG into Math.
1 parent 115afbc commit 65ead45

2 files changed

Lines changed: 21 additions & 6 deletions

File tree

v3/src/math/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
var RND = require('./random-data-generator/RandomDataGenerator');
2+
13
module.exports = {
24

35
// CONSTs (makes them visible under Phaser.Math)
@@ -16,6 +18,9 @@ module.exports = {
1618
Pow2: require('./pow2/'),
1719
Snap: require('./snap/'),
1820

21+
// Random Data Generator
22+
RND: new RND(),
23+
1924
// Single functions
2025
Average: require('./Average'),
2126
Bernstein: require('./Bernstein'),

v3/src/math/random-data-generator/RandomDataGenerator.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,30 @@ var hash = function (data)
7979

8080
var RandomDataGenerator = function (seeds)
8181
{
82-
if (typeof seeds === 'string')
82+
if (seeds)
8383
{
84-
this.state(seeds);
85-
}
86-
else
87-
{
88-
this.sow(seeds);
84+
this.init(seeds);
8985
}
9086
};
9187

9288
RandomDataGenerator.prototype.constructor = RandomDataGenerator;
9389

9490
RandomDataGenerator.prototype = {
9591

92+
init: function (seeds)
93+
{
94+
console.log('RandomDataGenerator.init', seeds);
95+
96+
if (typeof seeds === 'string')
97+
{
98+
this.state(seeds);
99+
}
100+
else
101+
{
102+
this.sow(seeds);
103+
}
104+
},
105+
96106
/**
97107
* Reset the seed of the random data generator.
98108
*

0 commit comments

Comments
 (0)