Computer Science Canada Collision Detection Help |
Author: | ajones88 [ Mon Nov 23, 2009 6:41 pm ] | ||
Post subject: | Collision Detection Help | ||
What is it you are trying to achieve? I am creatign a tag game involving 2 ovals, when one oval touches another, the other person should become it. What is the problem you are having? Turing is not detecting a collision Describe what you have tried to solve this problem Tried whatdotcolor, didnt work because the red ovalw as always on top so it couldnt detect when the blue one collided, so i am trying with a simple collision detection. 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 Turing V. 4.1.1 |
Author: | Tony [ Mon Nov 23, 2009 7:19 pm ] | ||
Post subject: | RE:Collision Detection Help | ||
You've got the right idea, but try running this code
|
Author: | ajones88 [ Mon Nov 23, 2009 7:49 pm ] | ||
Post subject: | Re: Collision Detection Help | ||
Got it ![]()
|
Author: | ajones88 [ Mon Nov 23, 2009 8:00 pm ] |
Post subject: | Re: Collision Detection Help |
Also any help with a better detection for the diagonal radius would be apreciated. |
Author: | Tony [ Mon Nov 23, 2009 8:09 pm ] | ||
Post subject: | RE:Collision Detection Help | ||
You are creating a new variable in every iteration of the loop. Also, it your ovals are circles, then the sum of their radii will always be the same, regardless of the angle. |
Author: | ajones88 [ Mon Nov 23, 2009 8:22 pm ] | ||
Post subject: | Re: RE:Collision Detection Help | ||
Tony @ Mon Nov 23, 2009 8:09 pm wrote:
You are creating a new variable in every iteration of the loop. Also, it your ovals are circles, then the sum of their radii will always be the same, regardless of the angle. but if 2 "corner" edges are touching, the origin of the circles are farther apart |
Author: | Tony [ Mon Nov 23, 2009 8:31 pm ] |
Post subject: | RE:Collision Detection Help |
If I'm guessing at what you are talking about correctly, then you are talking about the case when distance equals to the sum of radii. In such a case, you should adjust your if conditions accordingly. |
Author: | ajones88 [ Mon Nov 23, 2009 9:49 pm ] |
Post subject: | Re: RE:Collision Detection Help |
Tony @ Mon Nov 23, 2009 8:31 pm wrote: If I'm guessing at what you are talking about correctly, then you are talking about the case when distance equals to the sum of radii. In such a case, you should adjust your if conditions accordingly.
how would i go about adjusting that. Ive played with it for a bit, but i cant seem to get it. Also, is there some sort of delay i can put in so it wont keep switching who is it while they are touching, as sometimes the same person emerges it. |
Author: | Tony [ Mon Nov 23, 2009 10:01 pm ] |
Post subject: | RE:Collision Detection Help |
how would you check if one number is less than or equals to another number? As for delays -- yes. You might want to wait for some time, see -- timemodule. |
Author: | ajones88 [ Mon Nov 23, 2009 10:12 pm ] |
Post subject: | RE:Collision Detection Help |
I want to be able to move, but dont want the value of red to change for ex. 1 second since it last changed. Correct me if i am wrong, but as far as i can tell, none of those do that. Thanks |
Author: | Tony [ Tue Nov 24, 2009 12:26 am ] |
Post subject: | RE:Collision Detection Help |
The only methods that are blocking are delay and DelaySinceLast. The rest return a value to you right away. |
Author: | ajones88 [ Tue Nov 24, 2009 5:43 pm ] | ||
Post subject: | Re: Collision Detection Help | ||
Got it ![]()
|