Computer Science Canada Need Help With Collisions & Boundaries |
Author: | Abbas_M [ Tue Jan 19, 2010 11:31 am ] | ||
Post subject: | Need Help With Collisions & Boundaries | ||
What is it you are trying to achieve? I'm making an easy screen saver in which there are two balls bouncing across the screen, and if they collide with each other then they should bounce off. What is the problem you are having? When the balls collide, they don't bounce off. The boundary of the Second Ball is not right as well. Describe what you have tried to solve this problem I tried to change the boundaries but couldn't get the right ones. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Turing_Gamer [ Tue Jan 19, 2010 5:39 pm ] |
Post subject: | Re: Need Help With Collisions & Boundaries |
For the collision of the 2 balls, reverse the direction of the 2 balls by having x, y, xdir, and ydir values for each ball. When they both collide, all directions should reverse by saying 'xdir := xdir * 1', etc. I havn't worked with radius in a long time so this is the best I can do... ![]() Hope it helps |
Author: | Abbas_M [ Wed Jan 20, 2010 10:14 am ] |
Post subject: | Re: Need Help With Collisions & Boundaries |
Thank You so much. Got it working. Thanks. |