So a kid in my class wanted more of a challenge...the professor gave us one...and I have no idea on this problem.

Here's the instructions:

Darts scorer. Write a program that draws a darts target and allows the user to click on the target to represent darts hitting the target. The program should output, in the window, a score for each click, and a running score for the entire game.

Scoring:

Landing a dart in the bull's eye is worth 50 points. A dart in the bull is worth 25 points. The outer ring is called the double ring. A dart in the double ring in the 20 section would be worth 40 points. A dart in the triple ring would be worth three times the score in that section. Darts in the areas between the rings and the bulls are worth the points on the outside of the target.

The player starts with 501 points, reducing the total by each score. The player must go out on an exact score, i.e. if the player has 10 points remaining, the player needs exactly 10 points to go out; throwing 12 will not work.

Here's the pic of what it's spose to look like-colors do not matter
http://www.dartbasics.com/images/dart_board.jpg

Here are two Python code smaples using the Tkinter GUI. Each example has a hint how to do the dart game:

from Tkinter import *

root = Tk()
root.title("Archery Target")

canvas = Canvas(root, width=600, height=600)
canvas.pack()

# draw five circles, largest one first, circles draw within a 
# square with given upper left corner and lower right corner coordinates
canvas.create_oval(50,50,550,550,fill='white',outline='white')
canvas.create_oval(100,100,500,500,fill='black',outline='black')
canvas.create_oval(150,150,450,450,fill='blue',outline='blue')
canvas.create_oval(200,200,400,400,fill='red',outline='red')
canvas.create_oval(250,250,350,350,fill='yellow',outline='yellow')

root.mainloop()

This tells you if the mouse has been clicked on target:

from Tkinter import *
import random

def create_rect():
    chance = random.sample(range(1, 250), 4)
    print chance  # test  eg. [72, 206, 116, 166]
    canvas.create_rectangle(chance, fill="red")

def check_rect(event):
    rect = canvas.find_overlapping(event.x, event.y, event.x, event.y)
    if rect:
        # delete old rectangle
        canvas.delete(rect)
        # create new rectangle
        create_rect()

root = Tk()
root.title("click on red")

canvas = Canvas(root, height=250, width=250, bg="yellow")
canvas.pack()

# create the starting random rectangle
create_rect()

# respond to left mouse button click
canvas.bind("<Button-1>", check_rect)

root.mainloop()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.