From 74b34803064eed90b960820bf09d51d5583e9750 Mon Sep 17 00:00:00 2001 From: Ben Burlingham Date: Sat, 28 Oct 2017 07:03:08 -0700 Subject: [PATCH] Randomizing hazard count. --- js/animation2a.js | 3 ++- js/animation2b.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/animation2a.js b/js/animation2a.js index ef3f68b..29f4800 100644 --- a/js/animation2a.js +++ b/js/animation2a.js @@ -73,7 +73,8 @@ Animation2a.prototype.createGlobalGrid = function() { const bounds = this.container.getBoundingClientRect(); const grid = new Grid(); - for (let i = 0; i < 2; i++) { + const n = Random.num(1, 3); + for (let i = 0; i < n; i++) { const w = Random.num(50, 200); const h = Random.num(50, 200); diff --git a/js/animation2b.js b/js/animation2b.js index fffeea4..83df344 100644 --- a/js/animation2b.js +++ b/js/animation2b.js @@ -14,7 +14,7 @@ function Animation2b() { this.container = document.getElementById('animation2b'); this.particles = []; - this.grid = createGlobalGrid(this.container, this.bounds); + this.grid = this.createGlobalGrid(this.container, this.bounds); const controls = new Controls( document.getElementById('controls2b'), @@ -68,10 +68,12 @@ Animation2b.prototype.updateSpeed = function(value) { this.particles.forEach(p => p.updateConfig({ speed: value })); } -function createGlobalGrid(container, bounds) { +Animation2b.prototype.createGlobalGrid = function() { + const bounds = this.container.getBoundingClientRect(); const grid = new Grid(); - for (let i = 0; i < 2; i++) { + const n = Random.num(1, 3); + for (let i = 0; i < n; i++) { const w = Random.num(50, 200); const h = Random.num(50, 200);