Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
a bouncing ball... stuck with direction changing
i am making a bouncing ball game (using awt) where the whole stage contains walls that are defined with startpoint and endpoint. the ball has center point and radius. i have managed to detect collisions and disallow crossing the walls (by putting the ball at the position of collision). now i am stuck with getting the new speed on x and y axis (where the ball would go on next step). the wall might be at any angle and the ball might reach the wall (or miss it) on any angle (or go parallel with it). as i said, the collision detection is perfect, but i cant get the new direction the ball should go. this must be expressed as speed on x and y axis. all variables are of type double
thanks in advance
0 · ·