From ac28185172db9e9579b0dc081671eebd192fa8db Mon Sep 17 00:00:00 2001 From: Simon Randby Date: Sat, 13 Jul 2019 10:48:06 +0200 Subject: [PATCH] Mention the existence of Random And say a bit about how and when to use --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 518ad6d..4a719ec 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,23 @@ Sometimes you want to squeeze in a new scene between two other scenes that you a Often you will perhaps only shorten the preceding scene and leave the start of the following scene intact. But for completeness, here is an example where we both shorten the previous scene, and chop down the beginning of the following scene. +### Randomness + +To ensure that random things happen consistently across runs it is recommended to use the `Random`-class rather than `Math.random()`. +Set up `Random` by initializing it in your constructor like so: +``` +constructor(id, options) { + ... + this.random = new Random('seedString'); + ... +} +``` + +Then use the random generator you just created like this: +``` +var randomNumber = this.random(); +``` + ### Time and timed events A lot of making a demo is syncing what's happening on the screen with the music.