I have problem with the bouncing ball, while creating it using class. The ball move but it stuck at the bottom of the page. Please help!!Thank you!!!
The ball move but it stuck at the bottom of the page.
class particle{ constructor(x,y,r){ this.x=x; this.y=y; this.r=r; } bounce(xSpeed, ySpeed){ this.xSpeed = xSpeed; this.ySpeed = ySpeed; if (this.x < 0 || this.x > width) { this.xSpeed *= -1; if (this.y < 0 || this.y > height) { this.ySpeed *= -1; } this.x += this.xSpeed; this.y += this.ySpeed; } display(){ fill(0,255,0); stroke(0); strokeWeight(1); circle(this.x,this.y,this.r); }}let balloon;function setup(){ createCanvas(windowWidth,windowHeight); balloon = new particle(100, 100, 100);}function draw(){ background(245); balloon.bounce(5,5); balloon.display(); }