# No, there is not in fact any recursion here
from turtle import *

t1 = Turtle()
t2 = Turtle()


go = 3
t1.lt(90)
t1.speed(1000)
t1.ht()


def gogo():
    go = 2
    while go > 1:
        if t1.xcor() < (window_width() / 2 - 50):
            for i in range(50):
                t1.fd(2)
                t1.rt(180 / 50)
        if t1.xcor() < (window_width() / 2 - 50):
            for i in range(50):
                t1.fd(2)
                t1.lt(180 / 50)

        else:
            print("done")
            print(xcor())
            go = 1

    while go > 0 and go < 2:
        if t1.xcor() > (window_width() / 2 - window_width() / 2 + 50):
            for i in range(50):
                t1.bk(2)
                t1.lt(180 / 50)
        if t1.xcor() > (window_width() / 2 - window_width() / 2 + 50):
            for i in range(50):
                t1.bk(2)
                t1.rt(180 / 50)
        else:
            print("home")
            go = 0
            onkey(gogo, "space")
            print("ready")


t2.ht()


onkey(gogo, "space")
listen()

print("ready")
