xxxxxxxxxx
36
var x = 200;
var speed = 2;
var shape = 200;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220);
circle(x, 200, shape);
// translate(200, 200);
x = x + speed;
if (x + 50 > width || x - 50 < 0) {
speed *= -1;
}
if (speed > 0) {
if (x > width / 2) {
shape = map(x, 0, width, 200, 100);
} else {
shape = map(x, 0, width, 100, 200);
}
} else {
if (x > width / 2) {
shape = map(x, 0, width, 50, 100);
} else {
shape = map(x, 0, width, 100, 50);
}
}
}
// if () {}