We are about to switch to a new forum software. Until then we have removed the registration on this forum.
¡Hi everyone!
I'm a Processing amateur, I don't know much yet about Processing, but the thing is, I have spent the last two days trying to figure out HOW TO Make a Ball Collide a Diagonal line.
I used something like this to make the ball collide a straight line (x or y):
if (position of the ball is bigger than 'this X'){ make the ball change direction; }
BUT i haven't been able to apply this to a diagonal.
PLEASE Help me.... I am very obsessed with this.
Thank you very much!!
Answers
http://www.JeffreyThompson.org/collision-detection/line-circle.php
Thank you, but I still can't make the ball collide to the line. I mean: change direction when it collides the line
Did you check the link provided?
If you are working with two circles, you check their collisions but checking the distance between their centers and comparing this distance against the sum of their radii. Let's say, if both circles have a radius of one, then a collision occurs when their distance is less or equal to 2:
For distance, you can use the distance function: https://processing.org/reference/dist_.html
For bouncing effects, you will need to keep track of their previous position. This will be the easiest approach for starters.
Kf