Skip to content

Commit 1a5bbbb

Browse files
authored
Merge pull request #522 from ninjadev/mention-random-in-readme
Mention the existence of Random
2 parents 4323c13 + ac28185 commit 1a5bbbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,23 @@ Sometimes you want to squeeze in a new scene between two other scenes that you a
145145
Often you will perhaps only shorten the preceding scene and leave the start of the following scene intact.
146146
But for completeness, here is an example where we both shorten the previous scene, and chop down the beginning of the following scene.
147147

148+
### Randomness
149+
150+
To ensure that random things happen consistently across runs it is recommended to use the `Random`-class rather than `Math.random()`.
151+
Set up `Random` by initializing it in your constructor like so:
152+
```
153+
constructor(id, options) {
154+
...
155+
this.random = new Random('seedString');
156+
...
157+
}
158+
```
159+
160+
Then use the random generator you just created like this:
161+
```
162+
var randomNumber = this.random();
163+
```
164+
148165
### Time and timed events
149166

150167
A lot of making a demo is syncing what's happening on the screen with the music.

0 commit comments

Comments
 (0)