Ex_01_02_Ball

Ball
PVector

PVector location;
PVector velocity;

void setup(){
  size(600,600);
  background(255);
  location = new PVector(100,100);
  velocity = new PVector(2.1,3.9);
}

void draw(){
  
  location.add(velocity);
  
  if ((location.x < 0)||(width < location.x)){
    velocity.x = velocity.x * -1;
  }
  if ((location.y < 0)||(height < location.y)){
    velocity.y = velocity.y * -1;
  }
  
  fill(255,32);
  rect(0,0,width,height);
  
  fill(0);
  ellipse(location.x,location.y,30,30);
}