xxxxxxxxxx
33
let angle,
bob,
length,
origin,
angleV,
angleA,
gravity;
function setup() {
createCanvas(600, 400);
angle = QUARTER_PI;
bob = createVector();
length = 150;
origin = createVector(300, 150);
angleV = 0;
angleA = 0;
gravity = 1;
}
function draw() {
translate(origin);
background(0);
stroke(255);
strokeWeight(8);
fill(127);
bob = createVector(sin(angle) * length, cos(angle) * length);
line(0, 0, bob.x, bob.y);
circle(bob.x, bob.y, 64);
angleA = -1 * sin(angle) * gravity;
angleV += angleA;
angle += angleV / length;
}