xxxxxxxxxx
let p, v, a;
// p 位置 v 速度 a 加速度
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
// 決定球的初始位置、速度、加速度
p = createVector(width/2, height/2);
v = createVector(0, 0);
a = createVector(0, 0.1);
}
function draw() {
p.add(v);
v.add(a);
// sin 波狀
v.x+=sin(p.y/10);
v.y+=sin(p.x/10);
// v.x=random(-5, 5);
// v.y=random(-5, 5);
fill(255,p.y/5,255);
circle(p.x, p.y, 50);
}