pygame:把框的伸缩动画成功模拟出来,但是他把每一次的动画都画出来了,怎么才能成功把动画做出来

我在gml里面做过,可是他的drawrect跟pygame的不一样,或者说我是理解错了?

清屏肯定不行,很多地方我还要用到画笔

http://2z86114f31.picp.vip/RPG/index.html

每绘制一帧之前先清除画布

import pygame
import sys

WHITE=255,255,255
BLACK=0,0,0

x1 = 270
x2 = 370
y1 = 270
y2 = 370

fps = pygame.time.Clock()
pygame.init()
screen = pygame.display.set_mode((640,480),pygame.RESIZABLE)


def drawkuang(fx1,fx2,fy1,fy2,speed):
    global x1,x2,y1,y2
    if speed == 0:
        pygame.draw.rect(screen,WHITE,(fx1,fy1,abs(fx2 - fx1),abs(fy2 - fy1)),5)
    else:
        for _a in range(speed):
                x1 += (fx1 - x1) * 0.2
                x2 += (fx2 - x2) * 0.2
                y1 += (fy1 - y1) * 0.2
                y2 += (fy2 - y2) * 0.2
                pygame.draw.rect(screen, WHITE, (x1,y1,abs(x2 - x1),abs(y2 - y1)), 5)

def main():


    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        drawkuang(20,620,270,370,20)

        fps.tick(60)
        pygame.display.flip()


if __name__ == "__main__":
    main()