Circular Collision Detection question
Author |
Message |
Abbas_M
|
Posted: Sun Jan 17, 2010 2:16 pm Post subject: Circular Collision Detection question |
|
|
What is it you are trying to achieve?
I want to know how to use circular collision detection between to images imported into turing for my game.
What is the problem you are having?
i dont know how to find the radius of the two images that will be coliding since the command to draw pictures is something
Pic.Draw (image, x, y, picMerge) it doesnt have the x2 and y2 values which are the radius so how would i find the radius of these images.
Describe what you have tried to solve this problem
Read numerous tutorials tried to put 2 more values in the Pic.Draw command but it was to many parameters
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
% The two images that need the radius found the second images is a moving ship so the x and y values change.
Pic.Draw (zombie, 15, 400, picMerge)
Pic.Draw (ship, x1, y1, picMerge)
%need to find radius_1 for the first image and radius_2 for second image in order for my collision detection to work properly.
if Math.Distance (x1, y1, x2, y2 ) < (radius_ 1 + radius_ 2) then
put "The objects have collided"
exit
end if
|
Please specify what version of Turing you are using
4.1.1
All help is appreciated. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Sun Jan 17, 2010 2:33 pm Post subject: Re: Circular Collision Detection question |
|
|
If they take up the full width and height of the image, you can use
code: |
r = Pic.Width(img) div 2
|
which will give you the radius (since it takes up the entire size of the image, and radius is diameter/2) If your images don't take up the entire width, open them in an image editor and find out, or guess.
Either way though, your collision detection will not check for collisions accurately, as x1 and y1 refer to the lower left corner of the image, not the center. |
|
|
|
|
|
Abbas_M
|
Posted: Sun Jan 17, 2010 2:40 pm Post subject: Re: Circular Collision Detection question |
|
|
i tryed using for rectangular collision detection but for some reason i fail and it does not work correctly.
Edit: it worked fine so far... thanks for the help appreciate it. now on to other problems . |
|
|
|
|
|
|
|