summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/draw.js1
-rw-r--r--client/index.js11
-rw-r--r--client/lib/util.js2
3 files changed, 10 insertions, 4 deletions
diff --git a/client/draw.js b/client/draw.js
index 3ff6620..0a86d4a 100644
--- a/client/draw.js
+++ b/client/draw.js
@@ -18,7 +18,6 @@ function resize(){
document.body.addEventListener('resize', resize)
resize()
-
function clear(n){
ctx.fillStyle = 'rgba(255,255,255,' + (n || 0.5) + ')'
ctx.fillRect(0,0,w,h)
diff --git a/client/index.js b/client/index.js
index 024c2d4..fbe0491 100644
--- a/client/index.js
+++ b/client/index.js
@@ -34,16 +34,23 @@ keys.listen(index => {
if (last_index !== index) {
samplers['smash'].play(randrange(90, 150) + index, 0)
last_index = index
+ draw.clear()
+ draw.triangle(window.innerWidth/2, window.innerHeight/2, 500)
}
else if (Math.random() < 0.09) {
last_index = -1
}
- for (var i = 0; i < count; i++) {
+ let when, i
+ for (i = 0; i < count; i++) {
// kalimba.play(freq * (i+1)/4, now + Math.random()/(i+1))
+ when = Math.random()/2000 + (i + Math.random()/10)/randrange(2,5)
samplers['glass'].play(
100 + index*(Math.random() * 10),
- now + (Math.random()/2000 + i/10)
+ now + when
)
+ setTimeout( () => {
+ draw.triangle(randint(window.innerWidth), randint(window.innerHeight), randrange(10, 100))
+ }, when * 1000)
}
})
diff --git a/client/lib/util.js b/client/lib/util.js
index 6d8577a..48145e0 100644
--- a/client/lib/util.js
+++ b/client/lib/util.js
@@ -14,7 +14,7 @@ const browser = { isIphone, isIpad, isMobile, isDesktop }
function clamp(n,a,b){ return n<a?a:n<b?n:b }
function choice (a){ return a[ Math.floor(Math.random() * a.length) ] }
function mod(n,m){ return n-(m * Math.floor(n/m)) }
-function randint(n){ return Math.random(n)|0 }
+function randint(n){ return (Math.random()*n)|0 }
function randrange(a,b){ return a + Math.random() * (b-a) }
function randsign(){ return Math.random() >= 0.5 ? -1 : 1 }