![スクリーンショット 2018-02-05 22.26.09.png](https://qiita-user-contents.imgix.net/https%3A%2F%2Fqiita-image-store.s3.amazonaws.com%2F0%2F45520%2F19347dee-55da-9ca7-2934-b175a39f6a5f.png?ixlib=rb-4.0.0&auto=format&gif-q=60&q=75&s=a0d4316f2f3e610c97ad0f680c853daf)
PVector location;
PVector velocity;
void setup(){
size(1024, 768);
frameRate(60);
stroke(194,24,91);
fill(233,30,99,127);
location = new PVector(40,40);
velocity = new PVector(2,5);
}
void draw(){
background(15);
ellipse(location.x,location.y,20,20);
location.add(velocity);
if(location.x < 0 || location.x > width){
velocity.x = velocity.x * -1;
}
if(location.y < 0 || location.y > height){
velocity.y = velocity.y * -1;
}
}
class PVector{
float x;
float y;
PVector(float x_, float y_){
x = x_;
y = y_;
}
void add(PVector pvector){
x = x + pvector.x;
y = y + pvector.y;
}
}