xxxxxxxxxx
22
let WID = 400; let HIG = 400;
var ball = { x: WID/2, y: HIG/2, d: 23,
display: function() {
stroke(0); strokeWeight(4); fill(200,100,50);
ellipse(this.x, this.y, this.d)},
move: function() {
ball.x = ball.x + random(-2,2);
ball.y = ball.y + random(-2,2)
}
}
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
// ellipse(ball.x, ball.y, ball.d)
ball.display();
ball.move();
}