Results 1 to 7 of 7
  1. #1
    MarsTeam is offline Member
    Join Date
    Jun 2010
    Posts
    8
    Rep Power
    0

    Default 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!

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,816
    Rep Power
    25

    Default

    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.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    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

  4. #4
    MarsTeam is offline Member
    Join Date
    Jun 2010
    Posts
    8
    Rep Power
    0

    Default

    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!
    Last edited by MarsTeam; 06-22-2010 at 03:53 PM.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by MarsTeam View Post
    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

  6. #6
    MarsTeam is offline Member
    Join Date
    Jun 2010
    Posts
    8
    Rep Power
    0

    Default

    Quote Originally Posted by JosAH View Post
    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 : )

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,730
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by MarsTeam View Post
    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 ;-)

Similar Threads

  1. how can I draw a board in 2d array?
    By java_fun2007 in forum New To Java
    Replies: 8
    Last Post: 12-28-2011, 06:58 PM
  2. How to do a score board?
    By vlan in forum Java Applets
    Replies: 11
    Last Post: 06-03-2010, 11:10 AM
  3. need help making a game board
    By Don k in forum New To Java
    Replies: 2
    Last Post: 04-30-2010, 01:09 AM
  4. game board design
    By tomitu in forum New To Java
    Replies: 12
    Last Post: 02-27-2010, 06:31 PM
  5. how to create board in java...
    By zenith in forum New To Java
    Replies: 5
    Last Post: 01-20-2010, 05:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •