xxxxxxxxxx
37
class Ball {
construcor() {
this.x = 300;
this.y = 200;
this.xspeed = 4;
this.yspeed = -3;
}
}
move() {
x = x + xspeed;
y = y + yspeed;
}
bounce(){
if (x > width || x < 0) {
xspeed = xspeed * -1;
}
if (y > height || y < 0) {
yspeed = yspeed * -1;
}
}
display(){
stroke(255);
strokeWeight(4);
fill('#2196F3');
ellipse(x, y, 24, 24);
}