Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Circular Collision Detection question
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Abbas_M




PostPosted: 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
Sponsor
sponsor
TheGuardian001




PostPosted: 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




PostPosted: 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 Very Happy.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: