控制帧率的海龟画圆动画_control fps in turtle animation

"""
   控制帧率的海龟画圆动画_control fps in turtle animation
   本程序结合了pygame的时钟功能,这样能控制帧率fps
"""

import turtle
import pygame

screen = turtle.getscreen()   # 获取屏幕
screen.delay(0)
screen.tracer(0)              # 关闭自动刷新

turtle.shape('turtle')
turtle.penup()

fps = 60                      # 设定帧率
clock = pygame.time.Clock()

while True:
     turtle.fd(1)    
     turtle.rt(1)
     screen.update()          # 手动刷新
     screen.title(str(fps))
     clock.tick(fps)