From 1c2acd3320963884821d52530b24637abd88354f Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Wed, 28 Jun 2017 19:55:45 +0100 Subject: Causally air resistance. --- sketch.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'sketch.js') diff --git a/sketch.js b/sketch.js index 3cce527..2c6b9d3 100644 --- a/sketch.js +++ b/sketch.js @@ -1,5 +1,6 @@ var ps = []; var gravity; +var air_resistance = 0.5; var wid = 800; var hei = 600; @@ -14,6 +15,7 @@ function draw() { for(var i = ps.length - 1; i >= 0; i--) { ps[i].applyForce(gravity); + ps[i].applyDrag(air_resistance); ps[i].update(); stroke(ps[i].colour); @@ -30,7 +32,7 @@ function draw() { mouseX, mouseY, random(2, 8), color(random(0, 360), random(90, 100), random(50, 100)) ); - p.applyForce(createVector(random(-40, 40), random(-150, 0))); + p.applyForce(createVector(random(-200, 200), random(-400, 0))); ps.push(p); } } -- cgit v1.2.1