xxxxxxxxxx
27
//JSON object literal
let ball = {
x: 400,
y: 50,
size: 50,
r: 255,
g: 23,
b: 175,
};
function setup() {
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(220);
fill(ball.r, ball.g, ball.b);
ellipse(ball.x, ball.y, ball.size, ball.size);
ball.x = ball.x - 1;
}
function mousePressed() {
ball.x = mouseX;
ball.y = mouseY;
}