眠気を誘う玉
var rad = 150;
var xpos, ypos;
var xspeed = 13.0;
var yspeed = 13.0;
var xdirection = 1;
var ydirection = 1;
function setup() {
createCanvas(windowWidth,
windowHeight);
noStroke();
ellipseMode(RADIUS);
xpos = width / 2;
ypos = height / 2;
}
function draw() {
background(0, 0, 0);
fill(255, 255, 255);
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);
}