xxxxxxxxxx
37
let balls = [];
let x = 200;
let y = 50;
let mass = 20;
let vy = 1;
let ay = 0.75;
function setup() {
createCanvas(400, 400);
ay = mass * 0.015
}
function draw() {
background(0);
ball();
bounce();
print(y);
}
function ball() {
noFill();
stroke(255);
strokeWeight(4);
circle(200, y, mass);
}
function bounce() {
if (y > height) {
vy *= -0.6;
y = height;
}
vy += ay;
y += vy;
}