Ok I am show you how to use a common method of collision detection which is some times called rectangle collision detection. What it dose is uses if statements to make a theoretical rectangles arrowed the objects and then dose some tings if the rectangles hit.

Well here is an example of how to do this. This example uses two ovals which we wont to bounce off everything. (sorry for the bad spelling if I get time I will spell check it )

distance = ((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))**0.5
%you take the square of differences of X coordinates and add
%a square of differences of Y coordinates then take a square
%root of the sum
%%%%%%
%I did (x)*(x) instead of x**2 because exponents is a function
%and it takes up more resourses then *, thus its faster
%Also **0.5 is the same as sqrt() - learn your math guys

if distance < radious1 + radious2
%might be a good idea to save radious1+radious2 as const/var
then
collision = true
end if

I hope this little tutorial helped. If something is still unclear, or you want to know how to do other types of detections, please post.

This would be a good tutorial but I didn't label much but this is almost the same thing as the other one but with this you can change the number of bouncing balls by changing BALLCOUNT but only the first two balls say if they collided with each other.

I'm trying out a pool program... thanks for the rectangle collision program... However, I would like to make the collision more realistic as in a "real" pool bounce... I tried out the oval collision, but it seems as if the program only tells when it hits! I would like to find out if the balls can realistically bounce off each other in a real way. Please post any sort of help.

Tony

Posted: Wed Nov 27, 2002 12:35 am Post subject: (No subject)

ya, you can do that... you need to apply some physics and trig for it though... you should have no problem with grade11 knowledge of math and physics.

I will shortly post a new tutorial on this topic. Check out tutorial section for [trig]

when i click on a certain spot i want it to check if there is something within a certain radius of the point, say i click on (x,y)...i want to check if there is something within a 40 pixel radius of the spot ...any ideas are welcome....can u try to explain it to me because i dont wanna just see code and copy it (im lazy so if its there, i'll copy it ), if you hafta tho ..i dont mind... thanks alot.....this site is really helpful...and its a good oppurtunity for me to test my own skills by debuggin and helping others and receive help from you crazzy programmmers.......if i had a job i might give you pplz money for such an amazing site...its one of the very few on the net that have a point to them...alongside google and shockwave.com GOOD JOB!!!! i know its commentss like this that make your day j/k
im out...pz

Blade

Posted: Mon Apr 07, 2003 8:05 pm Post subject: (No subject)

use an if statement... lets say if you have a ball.... xy will be the mouse... so you make the forign object enter the radius of the mouse click.... then use an if statement to see if its there.. .such as
if forignobject < xy of ball + 40 then
the object has entered the radius

understand?

void

Posted: Mon Apr 07, 2003 8:18 pm Post subject: (No subject)

thanks alot ....i think i get it...but the thing is...what if its at like a 45 degree angle from the center (using a horizontal plane as 0 degreees and 180)...then how do you check it? lets say its a line headed at a circle at a 45 degree angle from the center of the circle....how would you check that?...because the xy only check the horizontal and vertical values does it not? the diagonals are completely ignored

SponsorSponsor

Blade

Posted: Mon Apr 07, 2003 8:38 pm Post subject: (No subject)

what happens if you add 40 to x, and y, then find the distance between the both then get the midpoint from that.... would that work?

okay....heres what im attempting to do....i wanna see what the distance is....by radius from the mouse and the point that i randomly set in there.....but the thing is....i get a value of 0 (which should mean im directly over the point) far too many...how many different (6,4)'s can there be.....i've tried switching the (x,y) to x1 and y1 positions istead of their current x2,y2 possition...but the result is still the same.....