# P5 game ball bouncing bug

**URL:** https://discourse.processing.org/t/p5-game-ball-bouncing-bug/6768
**Category:** Coding Questions
**Created:** [December 19, 2018, 11:05pm UTC](https://discourse.processing.org/t/p5-game-ball-bouncing-bug/6768 "2018-12-19T23:05:47Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![avafgrey](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@avafgrey](https://discourse.processing.org/u/avafgrey)
#### Post date: [December 19, 2018, 11:05pm UTC](https://discourse.processing.org/t/p5-game-ball-bouncing-bug/6768/1 "2018-12-19T23:05:47Z")

</div>

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](https://github.com/lizzybrooks/Bouncingball/blob/master/Test%20game%202/sketch.js)

---

<div class="post-metadata">

### Author: ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)
#### Post date: [December 20, 2018, 6:17am UTC](https://discourse.processing.org/t/p5-game-ball-bouncing-bug/6768/2 "2018-12-20T06:17:38Z")

</div>

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 && …

---

<div class="post-metadata">

### Author: ![avafgrey](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@avafgrey](https://discourse.processing.org/u/avafgrey)
#### Post date: [January 7, 2019, 9:23pm UTC](https://discourse.processing.org/t/p5-game-ball-bouncing-bug/6768/3 "2019-01-07T21:23:35Z")

</div>

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