bingkai kerja dalam modul kura -kura
import turtle
# this is not the best timer for this but it works okay:
from time import perf_counter as timer
# make the window:
wn = turtle.Screen()
wn.tracer(0)
wn.setup(0.7, 0.7)
# make the sprite you want to move:
t = turtle.Turtle()
t.speed(0)
t.shape('square')
t.shapesize(4, 4)
t.pu()
t.setx(-200)
t.speed = 2
# make the frame work variables
frameStartTime = timer()
delta_time = timer() - frameStartTime
# you can set it to any other number to see that this frame work is working good
fps_limit = 10
# main loop:
while True:
try:
# Frame Work update:
frameStartTime = timer()
while 1 / (timer() - frameStartTime) > fps_limit:
pass
delta_time = timer() - frameStartTime
delta_time *= 60
# move the sprite:
t.setx(t.xcor() + t.speed * delta_time)
# update the screen:
wn.update()
except:
break
DashCoder444