xxxxxxxxxx
37
// Friction Force
// The Nature of Code
// The Coding Train / Daniel Shiffman
// https://youtu.be/9IQEM_Ijklg
// https://thecodingtrain.com/learning/nature-of-code/2.3-friction.html
// https://editor.p5js.org/codingtrain/sketches/zcTpMCpA
let movers = [];
let mu = 0.05;
const colors = [
{r: 156, g: 0, b: 24},
{r: 252, g: 122, b: 0},
{r: 37, g: 7, b: 95},
{r: 9, g: 60, b: 64},
{r: 244, g: 5, b: 9},
{r: 254, g: 208, b: 1},
{r: 3, g: 0, b: 213},
{r: 0, g: 0, b: 0},
];
function setup() {
createCanvas(600, 400);
for (let i = 0; i < colors.length; i++) {
movers[i] = new Mover(random(width), random(height), 4, colors[i]);
}
}
function draw() {
background(39, 119, 20);
for (let mover of movers) {
mover.friction();
mover.update();
mover.edges();
mover.show();
}
}