Source Code :
import turtle
CROSS_SIZE = 20
def draw_circle(tur, x, y, radius, color="black"):
tur.color(color)
tur.pu()
tur.begin_fill()
tur.goto(x, y - radius)
tur.pd()
tur.circle(radius)
tur.end_fill()
def draw_plus(tur, x, y, length=CROSS_SIZE):
tur.penup()
tur.goto(x, y - (length / 2))
tur.pendown()
tur.goto(x, y + (length / 2))
tur.penup()
tur.goto(x - (length / 2), y)
tur.pendown()
tur.goto(x + (length / 2), y)
print("Mouse click at", x, ",", y)
screen = turtle.Screen()
screen.title("Archery")
screen.setup(450, 450)
screen.bgcolor("cyan")
screen.listen()
cross_turtle = turtle.Turtle(visible=False)
cross_turtle.color("green")
cross_turtle.width(4)
cross_turtle.speed(0)
screen.onclick(lambda x, y, tur=cross_turtle: draw_plus(tur, x, y))
screen.onkey(lambda: cross_turtle.clear(), "space")
toby = turtle.Turtle()
toby.speed(0)
toby.width(5)
toby.hideturtle()
draw_circle(toby, 0, 0, 160, "black")
draw_circle(toby, 0, 0, 120, "blue")
draw_circle(toby, 0, 0, 80, "red")
draw_circle(toby, 0, 0, 40, "yellow")
turtle.done()
0 Comments