Android Question Dart board

Colin Evans

Active Member
Licensed User
Longtime User
Hi, I need to create a dart board, with four sections in each number (1-20 in standard dart board numbering), is this possible graphically?
 

klaus

Expert
Licensed User
Longtime User
now I need to work out how to use it in straight B4A not B4XPages, thanks again
There is nothing special.
The xDartboard is a b4xlib CustomView.
Two possiblities:
1. Use the b4xlib, you need to save it in the Additional\B4X folder (the folder for additional b4xlib libraries), and check xDartbord in the Libraries Manager Tab.
2. Load the xDartboard.bas file into the project folder.
Then, in the Designer AddView/CustomView/xDartboard
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
There is nothing special.
The xDartboard is a b4xlib CustomView.
Two possiblities:
1. Use the b4xlib, you need to save it in the Additional\B4X folder (the folder for additional b4xlib libraries), and check xDartbord in the Libraries Manager Tab.
2. Load the xDartboard.bas file into the project folder.
Then, in the Designer AddView/CustomView/xDartboard
Thanks again, I will have a go😂but if you have two minutes to knock a B4A version together it would be greatly appreciated
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Here you are.
Hi Klaus, just a quick question, using your code when the dartboard is touch it registers the change but reports it multiple times, is there an option to get the event of one click, I tried changing _change to _click but didn't work, sorry for my lack of understanding
 
Upvote 0

emexes

Expert
Licensed User
Longtime User
Hi Klaus, there seems to be no files attached

Lol the downside of operating at Klaus Speed - trying to keep up.

Use the updated .bas (class) file from post #28.

Start a new B4XPages project (I'm using B4J, but should work in B4A and B4I too).

Project menu, add existing modules, select the download xDartboard.bas, copy to project folder

Designer menu, open internal designer

Add view, customview, xDartboard

Drag to desired position and size (ideally squarish, ie same width and height)

Close (and save) designer

F5 to compile & run

Voila!

1758779174369.png


(ok, I left out one step to tidy up the visual positioning of the numbers - clue: change line 41 from 0.9 to 0.87, but you might prefer something different again)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Many, many thanks to Klaus for the library. Using his expertise, I managed to knock together the Killer Game to add to my Darts ScoreBoard Game, link to the full apk - Full Dart ScoreBoard apk
I've also knocked up a separate app, which I've attached the source code. One thing of note I managed to amend Klaus's class (Hope that is okay Klaus) it's in the source code as class module, basically to accommodate the allocation of the random numbers, and show visually on screen. Everyone starts with a pale blue segment of their number apart from the current player, which is shaded gold. To play the game, a player has to hit their own number three times, which then makes them a Killer, on their next turn they can attack the other players, when given a Killer status their active segment is shaded Dark Orange if the current player and Dark Blue if not active, A killer needs to attack other players, if the attacked are a killer they lose that status when hit, and subsequently lose a life on every hit. If you're a darts player I'm sure it will make sense 🤣
 

Attachments

  • DITL Killer.zip
    20.5 KB · Views: 6
  • 1000042873.png
    1000042873.png
    455 KB · Views: 26
  • Screenshot_20251001-121721.png
    Screenshot_20251001-121721.png
    55.7 KB · Views: 29
  • Screenshot_20251001-121749.png
    Screenshot_20251001-121749.png
    71.5 KB · Views: 29
  • Screenshot_20251001-121759.png
    Screenshot_20251001-121759.png
    283.1 KB · Views: 27
  • Screenshot_20251001-121836.png
    Screenshot_20251001-121836.png
    289.8 KB · Views: 26
  • Screenshot_20251001-121851.png
    Screenshot_20251001-121851.png
    286.2 KB · Views: 22
  • Screenshot_20251001-121916.png
    Screenshot_20251001-121916.png
    244.1 KB · Views: 29
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Many, many thanks to Klaus for the library. Using his expertise, I managed to knock together the Killer Game to add to my Darts ScoreBoard Game, link to the full apk - Full Dart ScoreBoard apk
I've also knocked up a separate app, which I've attached the source code. One thing of note I managed to amend Klaus's class (Hope that is okay Klaus) it's in the source code as class module, basically to accommodate the allocation of the random numbers, and show visually on screen. Everyone starts with a pale blue segment of their number apart from the current player, which is shaded gold. To play the game, a player has to hit their own number three times, which then makes them a Killer, on their next turn they can attack the other players, when given a Killer status their active segment is shaded Dark Orange if the current player and Dark Blue if not active, A killer needs to attack other players, if the attacked are a killer they lose that status when hit, and subsequently lose a life on every hit. If you're a darts player I'm sure it will make sense 🤣
Very good, Colin!

Now... copy everything and paste it here:
https://www.b4x.com/android/forum/forums/share-your-creations.33/
:D
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Nice application.
I had in mind to add the ability to highlight any area with the given ring and sector index..
I had not added it because i did not know the exact needs.
I am glad that you could adapt it to your specific needs.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I think that you have used the latest xDartborad module i had posted in this thread.
In the xDartboard thread the library was updated to version 1.2.
It corrects the sector colors. In version 1.1 the colors of sector 20 were green and white.
I changed them to red and black like the official dartboards.

To change this in your module:
In this code:
B4X:
    For i = 0 To 19
        'Adjust for dartboard orientation - the SectorNumber array starts at top (20)
        'but drawing starts 5 positions earlier, so we need to offset
        Dim adjustedIndex As Int = (i + 5) Mod 20
        Angle = i * 18 - 9
Change: Angle = i * 18 - 9
to: Angle = i * 18 - 99
 
Last edited:
Upvote 0
Top