Bouncing Circle: Make it bouncy, pt. 2

⌨️ Add a conditional to detect when the ball hits the right wall

image

In plain English, this new code says:

“If the x-position is greater than or equal to 400…”

Remember that 400 is the canvas width, and if x is greater than or equal to 400, that means x is touching (or past) the right edge of our canvas.

That sounds like a great place to reverse the circle’s direction of travel! 🤔

Next up...

Bouncing Circle: Make it bouncy, pt. 3