##Student Name: Wurong Weng
##Student Number: 1224989
##MacID: wengwr
##Date: Mar. 13, 2013

import math
from graphics import *

def distanceBetweenPoints(p1, p2):
    return math.sqrt((p1.getX() - p2.getX())**2 + (p1.getY() - p2.getY())**2)

def drawCircle(w, c, r, s):
    C = Circle(c, r)
    C.setFill(s)
    C.draw(w)
    return C

def circleGame():
    win = GraphWin("Circle Game", 500, 500)
    win.setCoords(0, 0, 100, 100)
    c = Point(50, 50)
    C = drawCircle(win, c, 30, "red")

    state = True
    while (state):
        p = win.getMouse()
        d = distanceBetweenPoints(p, c)
        r = C.getRadius()
        C.undraw()

        if d <= r/4:
            state = False
        elif d <= r and d > r/4:
            C = drawCircle(win, c, 0.8*r, "red")
        else:
            C = drawCircle(win, c, 1.1*r, "red")
    win.close()


##Design Question:
##    No, it would not be possible to write a program without an indefinite loop
##    that satisfies the requirements above because at first we do not know how
##    many times user will click the window so we can not set a range() in some
##    number.
##
##Test plan:
##    the good test cases for the program is repeatedly clicking inside or outside
##    the circle, and print out the radius of the circle & distance between mouse
##    click and the center of the circle ( print "d=",d,"\tr",r) to see if the program satisfies the
##    requirement.
 
