Example #1
0
def playTheGame(win, width):
    # Event loop, each time through fires a single shot
    angle, vel, height = 45.0, 40.0, 2.0
    # Interact with the user
    inputwin = InputDialog(angle, vel, height)
    target = Target(win, width, angle, vel, height)
    p = Point(100, 20)
    # Loop for striking the target
    while not (target.hit(p)):
        # Loop to shoot the projectile
        choice = inputwin.interact()
        if choice == "Quit":
            inputwin.close()
            return choice
        # Create a shot and track until it hits target or leaves window
        angle, vel, height = inputwin.getValues()
        shot = ShotTracker(win, angle, vel, height)
        p = checkForHit(shot, target)
        print("hitTarget=", target.hit(p))
    inputwin.close()
    return target.hit(p)