Computer Science Canada bouncing balls |
Author: | this_guy [ Sun Jul 25, 2004 3:53 pm ] |
Post subject: | bouncing balls |
i've been trying to get two balls to bounce off each other i tried using math.distnc to c whether 2 balls r touching, den hav dem change directions but dat didnt look real |
Author: | Paul [ Sun Jul 25, 2004 4:21 pm ] |
Post subject: | |
http://www.compsci.ca/v2/viewtopic.php?t=5246 |
Author: | Cervantes [ Mon Jul 26, 2004 6:49 am ] | ||
Post subject: | |||
note that my approach to circular collision does not work very well for top down views, though it is excellent for a side view, like slime-volleyball. for top-down, try thoughtful's approach:
|
Author: | DanShadow [ Mon Jul 26, 2004 6:35 pm ] |
Post subject: | |
or as done in many programs, create a cute, simple collision detection. Create a square with slightly smaller parameters than the circle, and make its center the same as the circles. If one of the immediate sides, or edges, or even the middle hits the other circle, write a procedure that checks which general direction (top_right,top_left,bottom_right,bottom_middle,etc. etc.) the opposing circle hits, and change the opposing balls direction to the opposite direction of its original direction, and maybe change its speed a bit. Lol, cheap, but it works. |
Author: | this_guy [ Tue Jul 27, 2004 3:06 pm ] |
Post subject: | |
wow thnx guys...except for danshadow...didnt get wut u said 1 problem, i looked at cervantes, but sometimes 2 balls would get stuck together and rotate around each other. that happened with smthg i tried 2, but dunno wut da prob is |
Author: | Cervantes [ Fri Jul 30, 2004 6:42 am ] | ||||
Post subject: | |||||
That is the part that tries to prevent the balls from sticking together. If you find that they are sticking together, do it again.
|
Author: | DanShadow [ Fri Jul 30, 2004 8:55 pm ] |
Post subject: | |
This is an example of what I meant.(the picture attached) [Open the file for this example] See the light blue square behind the circle? That is the offset for the radius in each corner. Now if a part of the second square around the second circle enters inside the first square of the first circle, it initiates a "collision" procedure which repels the second circle (and/or the first) in the opposite direction. If this clears up what I mean, my intention is fufilled. |
Author: | this_guy [ Tue Aug 03, 2004 4:02 pm ] |
Post subject: | |
oh! i c... kinda cheap, and fake especially if u hav a lot of diff circles. but its so much easier:D |
Author: | DanShadow [ Tue Aug 03, 2004 6:57 pm ] |
Post subject: | |
hehe, true, true. But a lot of people seem to use that! Its kind of weird, but if so many people do it, why not? ![]() |
Author: | Delta [ Thu Aug 05, 2004 11:36 am ] |
Post subject: | |
Because it's inefficient... use cervantes method which is about a hundred times better... I like how you have the engery transfer goin' on there cervantes real smooth use of physics lol... but ya... will balls... don't use a box for collisions... it's common sense... |
Author: | DanShadow [ Thu Aug 05, 2004 3:42 pm ] |
Post subject: | |
Im not saying you SHOULD use box collision detection, im just saying that quite a few people use it, and its easier if you dont understand physics. |