Browse Source

Get smoother less chaotic movement

main
Luke Murphy 4 years ago
parent
commit
9ed0a61246
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 16
      voicegardens/static/voicegardens.js

16
voicegardens/static/voicegardens.js

@ -55,7 +55,7 @@ var amplitude;
var duration;
// random shape positioning
var secondTick = false;
var positionTick = false;
var timer = 0;
function record() {
@ -390,8 +390,12 @@ function draw() {
smooth();
noStroke();
if (millis() >= 1000 + timer) {
secondTick = true;
// 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) {
positionTick = true;
timer = millis();
}
@ -414,11 +418,11 @@ function draw() {
shape.draw();
shape.move();
if (secondTick) {
if (positionTick) {
setTimeout(function() {
shape.destX = random(windowWidth);
shape.destY = random(windowHeight);
}, random(100, 3000));
}, random(1000, 5000));
}
if (shape.collide(shapes) === true) {
@ -426,7 +430,7 @@ function draw() {
}
}
secondTick = false;
positionTick = false;
}
function mouseDragged() {

Loading…
Cancel
Save