xxxxxxxxxx
30
class Ball {
constructor(x, y, r){
this.pos = createVector(x, y);
this.vel = createVector(2, 3);
this.r = r;
}
createCircle(){
fill(255, 255, 0);
ellipse(this.pos.x, this.pos.y, this.r, this.r);
}
moveCircle(){
this.pos.add(this.vel);
}
checkBorder(){
if (this.pos.x > width || this.pos.x < 0){
this.vel.x *= -1;
}
if (this.pos.y > height || this.pos.y < 0){
this.vel.y *= -1;
}
}
}