xxxxxxxxxx
PVector pos;//position
PVector vel;//velocity,速さ
int r=50;
void setup() {
size(960, 540);
colorMode(HSB, 360, 100, 100);
pos=new PVector(width/2, height/2);//初期化
vel=new PVector(2, 3);
}
void draw() {
background(220, 20, 20);
fill(0, 100, 100);
noStroke();
ellipse(pos.x, pos.y, r*2, r*2);
pos.add(vel);
if (pos.x>width-r||pos.x<0+r) {
vel.x=vel.x*-1;
}
if (pos.y>height-r||pos.y<0+r) {
vel.y=vel.y*-1;
}
}