summaryrefslogtreecommitdiff
path: root/client/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/index.js')
-rw-r--r--client/index.js26
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