P5 game ball bouncing bug


#1

I am trying to make a game with a ball that bounces off the platforms, but every once in a while the ball falls through the platform and I can’t figure out when or why.

https://github.com/lizzybrooks/Bouncingball/blob/master/Test%20game%202/sketch.js


#2

there is a problem with the x position you check in bounce

  • -a- pls make a variable like:
    var platlength=100;
  • -b- make the platform with:
    line(this.x, this.y,this.x+platlength, this.y);
  • -c- check the bounce with:
    if (this.x >= platforms[i].x && this.x <= platforms[i].x+platlength && …

#3

Thank you so much! <3 <3<3<3<3<3<3