I'm making an archery game and I need to shoot 5 arrows and assign a point value to each spot of the target. Bulls eye is worth 9 and each ring out from there is worth 2 less. I am having trouble figuring out how to assign a score to the target. I'm writing it in the getScore function to be called later on by main. Any advice?

Thanks! Here's part of my code

def drawTarget(win):
    center = Point(0,0)  # Center of target
    e = Circle(center,5) # largest circle
    e.setFill("white")
    e.draw(win)
    d = Circle(center,4)
    d.setFill("black")
    d.draw(win)
    c = Circle(center,3)
    c.setFill("blue")
    c.draw(win)
    b = Circle(center,2)
    b.setFill("red")
    b.draw(win)
    a = Circle(center,1) # smallest (bullseye) circle
    a.setFill("yellow")
    a.draw(win)

# allow user to place an arrow shot with the mouse and return the score associated
# with that show.  Place a small circle to show where the arrow hit.
def getScore(win):

    x = win.getMouse()
    c = Circle(x,.1)
    c.setFill("green")
    c.draw(win)

    p1 = x.getX()
    p2 = x.getY()

    #score = math.sqrt((p1)**2),p2**2)


    
    return 0 # needs to be replaced by real score

Recommended Answers

All 4 Replies

It might be worthwhile pointing out which of the many possible GUI modules you are using.

I think it looks like GraphWin.. but my GUI Knowledge is limited.

It was GraphWin sorry! I got it all figured out though, just had to figure out the distance from the center and return the score assigned to that circle. Thanks for responding everyone

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.