From 5d44e2d93b5ae56f2d9c46ae58e469ac803d9056 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 10 Apr 2020 15:04:10 -0600 Subject: [PATCH] remove down-right bias when bouncing normally --- js/ab-particles.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/ab-particles.js b/js/ab-particles.js index 10d526b..21dbfca 100644 --- a/js/ab-particles.js +++ b/js/ab-particles.js @@ -131,10 +131,21 @@ function particles(){ let size = (Math.random() * sizeMultiplier) + 1; // set X let x = (Math.random() * ((innerWidth - size * 2) - (size * 2)) + size * 2); - directionX = Math.random() * 5; + if (noBounceH){ + directionX = Math.random() * 5; + } + else{ + directionX = (Math.random() * 5) - 2.5; + } // set Y let y = (Math.random() * ((innerHeight - size * 2) - (size * 2)) + size * 2); - directionY = Math.random() * 5; + if (noBounceV){ + directionY = Math.random() * 5; + } + else{ + directionY = (Math.random() * 5) -2.5; + } + particlesArray.push(new Particle(x, y, directionX, directionY, size)); }