which type of collision detection would you recommend?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
cndr
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Sat Apr 24, 2010 7:03 am
Programming Language of Choice: etc.

which type of collision detection would you recommend?

Post by cndr »

I am using SDL and have a circle on screen which I would like to use for a button. Which method of collision detection would be best for this scenario?
Long Live The Queen!
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: which type of collision detection would you recommend?

Post by ibly31 »

For circles, I usually use pythagorean theorem to find the distance from the click to the center. If it's less than the radius, its inside. Only for circles though.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
MrDeathNote
ES Beta Backer
ES Beta Backer
Posts: 594
Joined: Sun Oct 11, 2009 9:57 am
Current Project: cocos2d-x project
Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
Programming Language of Choice: C/++
Location: Belfast, Ireland
Contact:

Re: which type of collision detection would you recommend?

Post by MrDeathNote »

ibly31 wrote:For circles, I usually use pythagorean theorem to find the distance from the click to the center. If it's less than the radius, its inside. Only for circles though.
Yea, this is pretty much the way to go for circles.
http://www.youtube.com/user/MrDeathNote1988

Image
Image

"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: which type of collision detection would you recommend?

Post by Ginto8 »

Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
cndr
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Sat Apr 24, 2010 7:03 am
Programming Language of Choice: etc.

Re: which type of collision detection would you recommend?

Post by cndr »

sorry for the delay, thanks for the help the Pythagorean theorem works great.
Long Live The Queen!
Post Reply