Hello... im trying to make a game for my java programming class at school because of an assignment... anyways... its a game where you have to get the bouncing ball thru a hole in the wall, something like pong. well, ive got it all pretty much figured out... the problem im having is the physics on the ball. i did research on this already, and after some testing, created a class Ball that worked well for my other bouncy ball related game, but not this one. here's the code for class ball:
this actually works kinda fine. the ball actually works like a real ball... it starts going sideways, then goes more downward, and bounces off the bottom of the screen, and basically does an arc. it works, except the fact that each successive bounce is the same height as the one before. and there are probably other flaws to. but it still kinda works, for my needs. but its not random enough. the path of the ball is the same, it iterates 3 different paths, then starts over. i need the ball to be much more random. just for clarification, it follows the same arc every time, and the drop angle, thats the same every time, is wats causing the ball to not go thru the hole in the wall. if somebody could help me out, that would be great, thanks.
For added randomness, each time the ball hits something, use a random number generator to "slightly" deviate the direction which the ball should go in so that the motion is more random!
3D OpenGL, C++ Game Development Video Tutorials @
Joined: Mar 05, 2008
It looks like your friction is always pointed in the same direction: -x and -y. Upward and to the left, I guess. So the ball slows down when it's falling downwards, but speeds up when it's moving upwards. You need the friction to change direction to always be opposite the direction of motion.