top of page

Code behind:

DartGame, Dartboard, 501

DartGame

DartGame initiates the game play, and connects all the user class objects into the same class.  DartGame is used to tell the users when the game has been won or lost and to connected the specific type of game to the active dartboard.  DartGame itself does not have a ton of built in functions, but it was needed as a class to centralize all of the game's users, the dartboard, and the score keeper.

Dartboard

Dartboard was one of the most difficult problems to solve.  We needed a way to receive the dart coordinates without using ginput.  I used the CurrentPoint property of the Figure to pinpoint the click’s location.  What was difficult was that the Figure was a rectangle and the polar plot was round and centered.  I had to hard code the Figure and normalize the axes to be a perfect square; this allowed me to subtract .5 from both the Cartesian coordinates of CurrentPoint, convert those new points to polar coordinates, and then determine the point value of the dart hit.  Once the dartboard was up and running, I could play practice games and ultimately help debug the entire system.  I also wrote the code in such a way that dartGame runs off of specific coordinates.  This will allow me to switch out the software dartboard with a hardware version in the future so I don’t even need to click on the computer, it just runs the game for me.

501

I had the most classic dart game assigned to me, 501.  I took 501 as my game to code because it is the most commonly played and I wanted it to be clean and efficient.  In my 501 game, players alternate turns hitting the board and trying to score 501 points exactly.  I tried to go above and beyond with this game version and built in an intel function that would take the users remaining points and recommend the easiest targets to hit to win.  The intel was difficult to write, and works 75% of the time.  I didn’t allow it to account for “miss” as an option, so if the player has 3 points left to win, it will recommend they shoot a single 1 three times instead of a single 3 and 2 misses.  These little bugs can be fixed, and I intend on having a high level intel function that helps players think less about what they should shoot.

Another awesome feature of 501 is after the game is won or loss.  I created a results page that allows the players to rematch immediately with all the same user settings, or they can view how they performed.  This performance screen has stats of average round score, number of misses, how many rounds it took to win, and where exactly the dartboard was clicked (allow the user to see their precision on the board).  All of these stats will be eventually stored in the user’s career profile, allowing them to analyze how they shoot or what their win-loss record has been.

Code gameboard501: About

Class Overviews

properties, methods, events

Below are screenshots explaining the main purpose of each property, method, and event for each class.

Code gameboard501: Gallery

Follow

  • LinkedIn

Contact

805 757 1685

Address

2908 Channing Way
Berkeley, California 94704
USA

©2017 by Kenneth Barton. Proudly created with Wix.com

bottom of page