I've added a function definition to tell my turtle to jump when you press the space bar. There is also a while True loop in my code, and whenever the space button is pressed, the while True loop freezes momentarily until the jump is finished and then carries on.
I've tried adding the function definition in the while True loop and outside. I can only put the function definition before the while True loop, because if I put it after the while True, the code will never reach it.
#making the player jump
def jump():
player.fd(100)
player.rt(180)
player.fd(100)
player.lt(180)
turtle.listen()
turtle.onkey(jump, "space")
I'm expecting the while True loop to not freeze, but wherever I've tried putting the def, it doesn't seem to work.
I also saw another answer to something similar to this, but didn't understand how I could apply that to my code.
Any other suggestions would be great.