Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / dark basic target score detection.

Author
Message
futsio
18
Years of Service
User Offline
Joined: 7th Jul 2006
Location:
Posted: 7th Apr 2007 22:03
Okay, I'm rubbish at maths. what's the algorythm needed to detect a circular collision?
for example- knowing whether you've hit the bullseye or any outer rings.
I've been using the sqrt(abs(x)+abs(y)) co-ords of the collision but that will only give me a dimaond shaped area, and I don't want a diamond shaped target.
I've been using all variations of cos and sin variables, but just can't get the thing.
HELP!
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 8th Apr 2007 01:43
Hello,

Quote: "algorythm needed to detect a circular collision?"


from the description of trying to find the hit areas in relation to the rings on a target, I don't think circular collision algorithms are what you are really after. That can get quite complicated. I think all you need is a radius.

For example, if you have a flat target with rings painted on it and you shoot arrows at it, you want the program to tell you which ring is being hit. Each ring (including the bullseye) is a certain distance from the center. On a circle this is a radius. The outer rings will have a larger radius than the inner rings. You could use a distance calculation radius=sqrt((x-centerx)^2,(y-centery)^2) where x and y is the point the arrow hits and centerx and centery are the center of the target and if the value falls in between the width of a ring, then you know the hit is in the particular ring.

ring1:
if radius < 10 and radius > 5 then ring1=hit
ring2:
if radius < 15 and radius > 10 then ring2=hit

etc.

Enjoy your day.

Login to post a reply

Server time is: 2025-05-27 22:44:51
Your offset time is: 2025-05-27 22:44:51