# Making a dart-board

• 06-22-2010, 09:22 AM
MarsTeam
Making a dart-board
Hello,
my problem is that I want to make a program to simulate games of playing darts. What I need to do is to have image/model of dart board, and user just clicks on areas where he, let's say, threw his dart, and it will count his score (like 20, double 15, 6 etc...).

Problem is, how do I determine what number did he score from dart board image ? Or is there better approach ? How would you build a program like this ?

Thanks for help!
• 06-22-2010, 02:11 PM
Norm
Quote:

how do I determine what number did he score from dart board image
You'll need to map the x,y positions for each section. That's usually done manually if the board is an image. You write a simple mapping program that shows where the mouse click is and save those x,y positions for the corners of each area. Very tedious.
If you build the display of the board in the program you could use polygons to map the different areas. Not quite a tedious but takes a bit of time it get it to look right.
• 06-22-2010, 02:57 PM
JosAH
You can also find the score mathematically: a dartboard is divided in 20 equal regions with an angle with of 2*PI/20 each. For each region you can find the start angle and the end angle (which is the start angle + 2*PI/20 radians). A small array with the scores maps the angle to a basic score.

The second measurement is the distance from the midpoint; if it is less than r (I don't know that value) you have hit the bulls eye; if it is less than r2 > r you have hit the area next to the bull's eye etc. for triple score and double score.

The Math.atan2(double y, double x) method can find the angle measured in radians for you.

kind regards,

Jos
• 06-22-2010, 03:45 PM
MarsTeam
That's what I though :)
was only curious whether there isn't some other way in Java for this, because as ex-C programmer it surprises me every day !

Thanks anyway!
• 06-22-2010, 04:12 PM
JosAH
Quote:

Originally Posted by MarsTeam
That's what I though :)
was only curious whether there isn't some other way in Java for this, because as ex-C programmer it surprises me every day !

Thanks anyway!

Well then, think of it how you would solve it in C; the translation to Java is easy.

kind regards,

Jos
• 06-22-2010, 08:44 PM
MarsTeam
Quote:

Originally Posted by JosAH
Well then, think of it how you would solve it in C; the translation to Java is easy.

kind regards,

Jos

I meant if there isn't some kind of DartsIHaveEverythingPreparedForYou component : )
• 06-22-2010, 08:54 PM
JosAH
Quote:

Originally Posted by MarsTeam
I meant if there isn't some kind of DartsIHaveEverythingPreparedForYou component : )

Nope, it only has the DartsIHaveEverythingPreparedForYouIfYouDontMindOst richesEatingYourInternetConnection class, but it is in the javax package so it's not sure if it'll stay ...

kind regards,

Jos ;-)