I'm trying to make an object (dot) float around the screen smoothly using the turtle library, but the movement on that is being produced right now is very "laggy" and "jumpy". Is there any way to fix this? If not, is there another library I can use to animate a dot floating around the screen?
# screen
Screen = turtle.Screen()
Screen.title("Moving Block")
Screen.bgcolor("black")
Screen.setup(width=1000, height=700)
# game
Block = turtle.Turtle()
Block.speed(0)
Block.shape("square")
Block.color("grey")
Block.penup()
Block.turtlesize(5,5)
Block.goto(0, 0)
# movement
def go_up():
y = Block.ycor()
if y <= 290:
Block.sety(y + 10)
def go_down():
y = Block.ycor()
if y >= -280:
Block.sety(y - 10)
def go_left():
x = Block.xcor()
if x >= -440:
Block.setx(x - 10)
def go_right():
x = Block.xcor()
if x <= 430:
Block.setx(x + 10)
# keyboard
Screen.onkey(go_up, "Up")
Screen.onkey(go_down, "Down")
Screen.onkey(go_left, "Left")
Screen.onkey(go_right, "Right")
Screen.listen()
Screen.mainloop()