解放された点P
var rad = 130;
var xpos, ypos;
var xspeed = 120;
var yspeed = 332;
var xdirection = 1;
var ydirection = 1;
function setup() {
createCanvas(windowWidth,
windowHeight);
noStroke();
ellipseMode(RADIUS);
xpos = width / 3;
ypos = height / 2;
}
function draw() {
background(11, 21, 3);
fill(223, 204, 501);
xpos = xpos + xspeed * xdirection;
ypos = ypos + yspeed * ydirection;
if (xpos > width - rad || xpos < rad) {
xdirection *= -1;
}
if (ypos > height - rad || ypos < rad) {
ydirection *= -1;
}
ellipse(xpos, ypos, rad, rad);
}