No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with
17 additions and
6 deletions
-
voicegardens/static/voicegardens.js
|
|
@ -57,7 +57,9 @@ var duration; |
|
|
|
|
|
|
|
// random shape positioning
|
|
|
|
var positionTick = false; |
|
|
|
var timer = 0; |
|
|
|
var secondTick = false; |
|
|
|
var secondTimer = 0; |
|
|
|
var positionTimer = 0; |
|
|
|
|
|
|
|
function record() { |
|
|
|
/** |
|
|
@ -503,10 +505,17 @@ function draw() { |
|
|
|
// count random waiting times in seconds until choosing a new destX, destY
|
|
|
|
// for a moving shape
|
|
|
|
let nextPositionTick = random(3000, 8000); |
|
|
|
let tickingTime = millis(); |
|
|
|
if (tickingTime >= nextPositionTick + timer) { |
|
|
|
let positionTickingTime = millis(); |
|
|
|
if (positionTickingTime >= nextPositionTick + positionTimer) { |
|
|
|
positionTick = true; |
|
|
|
timer = millis(); |
|
|
|
positionTimer = millis(); |
|
|
|
} |
|
|
|
|
|
|
|
let nextSecondTick = 1000; |
|
|
|
let secondTickingTime = millis(); |
|
|
|
if (secondTickingTime >= nextSecondTick + secondTimer) { |
|
|
|
secondTick = true; |
|
|
|
secondTimer = millis(); |
|
|
|
} |
|
|
|
|
|
|
|
// offset the window view based on new values of x,y related to the screen.
|
|
|
@ -558,10 +567,12 @@ function draw() { |
|
|
|
// play recordings when shapes collide
|
|
|
|
let [collision, collidedShape] = shape.collide(shapes); |
|
|
|
if (collision === true) { |
|
|
|
if (secondTick) { |
|
|
|
shape.sound(); |
|
|
|
collidedShape.sound(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// reset random shape position time ticker
|
|
|
|
positionTick = false; |
|
|
|