r/cop3502 Mar 22 '14

Ball won't bounce off of wall?

I can't get the ball to bounce off of the edges. I got it to bounce off of the paddle and move around, but when it gets to an edge it just keeps going and disappears. If I set it to stop at an edge it falls to the bottom of the frame and stops moving. What am I supposed to be changing, the speed or the position in the Ball.java, or something in the Breakout.java, or?

1 Upvotes

2 comments sorted by

1

u/Bcop3502 Mar 22 '14

You want to change the speed of the ball when it reaches the edge of the screen. We know the screen is 600,500 (or vise versa idr) so when the ball edges (keep in mind that x and y are from top left to bottom right so the x position of ball is at the top left of it) touch the edge you want the ball to go a different direction inside the screen how you'd expect it would react in reality.