xxxxxxxxxx
37
var cir = {
x: 50,
y: 200,
radius: 50,
speed: 3
};
var col = {
r: 0,
g: 0,
b: 0
};
function setup() {
createCanvas(600, 400);
}
function draw() {
background(col.r, col.g, col.b);
display();
move();
}
function display() {
stroke(255);
noFill();
strokeWeight(4);
ellipse(cir.x, cir.y, cir.radius * 2, cir.radius * 2);
}
function move() {
cir.x += cir.speed;
if (cir.x + cir.radius >= width)
cir.speed = -cir.speed;
if (cir.x - cir.radius <= 0)
cir.speed = -cir.speed;
}