Randomizing hazard count.

master
Ben Burlingham 8 years ago
parent c0a0be791e
commit 74b3480306
  1. 3
      js/animation2a.js
  2. 8
      js/animation2b.js

@ -73,7 +73,8 @@ Animation2a.prototype.createGlobalGrid = function() {
const bounds = this.container.getBoundingClientRect(); const bounds = this.container.getBoundingClientRect();
const grid = new Grid(); 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 w = Random.num(50, 200);
const h = Random.num(50, 200); const h = Random.num(50, 200);

@ -14,7 +14,7 @@ function Animation2b() {
this.container = document.getElementById('animation2b'); this.container = document.getElementById('animation2b');
this.particles = []; this.particles = [];
this.grid = createGlobalGrid(this.container, this.bounds); this.grid = this.createGlobalGrid(this.container, this.bounds);
const controls = new Controls( const controls = new Controls(
document.getElementById('controls2b'), document.getElementById('controls2b'),
@ -68,10 +68,12 @@ Animation2b.prototype.updateSpeed = function(value) {
this.particles.forEach(p => p.updateConfig({ speed: 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(); 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 w = Random.num(50, 200);
const h = Random.num(50, 200); const h = Random.num(50, 200);

Loading…
Cancel
Save