diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-02-25 16:42:27 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-02-25 16:42:27 +0100 |
| commit | a06393ed3864dd29626c741ada05df5380b9dfb8 (patch) | |
| tree | a2b4606e80c70cf8bb0f39e7566f9f9b69767085 /client | |
| parent | e54f99287a24fccae52ffdee1e55c6213bf6e9b6 (diff) | |
choice of glider shapes
Diffstat (limited to 'client')
| -rw-r--r-- | client/index.js | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/client/index.js b/client/index.js index 82be8e0..b9b7a03 100644 --- a/client/index.js +++ b/client/index.js @@ -3,7 +3,7 @@ import color from './lib/color' import kalimba from './lib/kalimba' import life from './lib/life' import organ from './lib/organ' -import { browser, requestAudioContext } from './lib/util' +import { browser, requestAudioContext, choice } from './lib/util' let instrument = kalimba @@ -55,18 +55,26 @@ function assign(freq, state) { function toggle(freq) { assign(freq, freq.playing = !freq.playing) } +const gliderShape = [ + [0,0,0,0,0], + [0,1,1,1,0], + [0,0,0,1,0], + [0,0,1,0,0], + [0,0,0,0,0], +] +const gliderShapeFlip = gliderShape.map(a => a.reverse()) +const gliderShapes = [ + gliderShape, + gliderShapeFlip, + gliderShape.reverse(), + gliderShapeFlip.reverse(), +] function glider() { const x = Math.floor(Math.random() * ws) const y = Math.floor(Math.random() * hs) console.log("glider at", x, y) - const gliderShape = [ - [0,0,0,0,0], - [0,1,1,1,0], - [0,0,0,1,0], - [0,0,1,0,0], - [0,0,0,0,0], - ] - weave(x,y,gliderShape) + const shape = choice(gliderShapes) + weave(x,y,shape) } function weave (x,y,shape) { const xmag = shape.length |
