import turtle
import math
wn = turtle.Screen()
wn.bgcolor("lightblue")
radius = 5
# Turtle
charlie = turtle.Turtle()
bri = turtle.Turtle()
charlie.shape("circle")
bri.shape("circle")
area = math.pi * radius ** 2
r2 = int(radius * 2)
while True:
#output
print('This is a program to do collision detection')
print('The balls have the same radius of {}.'.format(radius))
# input
x1_str = input("Enter the x coordinate of circle 1:")
y1_str = input("Enter the y coordinate of circle 1:")
x2_str = input("Enter the x coordinate of circle 2:")
y2_str = input("Enter the y coordinate of circle 2:")
x1 = int(x1_str)
y1 = int(y1_str)
x2 = int(x2_str)
y2 = int(y2_str)
# formula
d = int(math.sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)))
d
print("Distance: ", d)
print(r2)
charlie.goto(x1,y1)
bri.goto(x2,y2)
# hit
if d > r2:
print('no Collision')
elif d < r2:
print('collision detected')
elif d == r2:
print('Colision detected')
# restart (rough)
print("This is the end")
#if user enters "q" then quit the program
command = input("Enter 'q' to quit ")
if command == 'q':
break
radius = input("Do you want to change your radius(no)? ")
if radius == ('no'):
radius = 5