How can I make the ball bounce in pong? I want to be able to bounce the ball of the wall and have it go in the relative direction. It's no fun when the ball bounces straight back and forth...
Thanks. That's pretty cool, but it's not really what I need, unless I can figure out how to change the code to make the code automatic. I need the ball to bounce around without having to press buttons. You should know what I'm talking about, everyone has played pong before...
If I understand you right you really want to know the basics
so what you need to do for the ball to move automatically is increase the X and Y of the ball by Xspeed and Yspeed. Sastraxi described how to change the X- and Y-speed on collision with the walls.
But that still would not make the ball move in different angles. So what you should do is if the ball hits the paddle further at the left you should decrease the xspeed value and if you hit it further on the right increase the xspeed value.
I hope this was kind of understandable.
Just ask if there are more questions. ( I can look for some old Pong games I wrote long time ago)